'Noise Checker - wxv722-6
'Uses Dictionary.GetDefinition(word) - Need internet access
'Harry Hardjono
'July 2012 - adjective and adverb marker. Good for filtering nasty posts. :)
' just change color red and yellow to black.
'Updated with dict.txt
'
Str="abcdefghijklmnopqrstuvwxyz'ABCDEFGHIJKLMNOPQRSTUVWXYZ"
ReadDictFile()
inputtext=""
DataFile=""
While (inputtext<>" ")
TextWindow.WriteLine(" ")
TextWindow.WriteLine("Enter file name: ")
FileDir=text.Append(Program.Directory,"\")
WT="1=black;2=white;"
WriteText()
DataFile=File.ReadContents(text.Append(FileDir,Textwindow.read()))
inputtext=text.Append(DataFile," ")
counteradv=0
counteradj=0
counterunk=0
counterwrd=0
For i=1 To Text.GetLength(inputtext)
If (Text.GetIndexOf(Str,Text.GetSubText(inputtext,i,1))=0) Then 'Not word
If (Word<>"") Then
GetDictWord()
If (DictWord="") Then
WT="1=white;2=black;"
WriteText()
Else
fword=DictWord
adjloc=text.GetIndexOf(fword,"adjective")
advloc=text.GetIndexOf(fword,"adverb")
unkloc=text.GetIndexOf(fword,"unknown")
rploc=text.GetIndexOf(fword,")")
If (adjloc
WT="1=red;2=black;"
WriteText()
counteradj=counteradj+1
ElseIf (advloc
WT="1=yellow;2=black;"
WriteText()
counteradv=counteradv+1
ElseIf (unkloc
WT="1=white;2=black;"
WriteText()
counterunk=counterunk+1
Else
WT="1=black;2=white;"
WriteText()
counterwrd=counterwrd+1
EndIf
EndIf
Word=""
EndIf
TextWindow.Write(Text.GetSubText(inputtext,i,1))
Else 'Word
Word=Text.Append(Word,Text.GetSubText(inputtext,i,1))
EndIf
endfor
ShowNoiseRatio()
EndWhile
WriteDictFile()
'===============================
'Program ends here
'===============================
Sub ShowNoiseRatio
NR=Math.Round(1000*(counteradj+counteradv)/counterwrd)/10
NRT="Noise Level Interpretation"
If (NR<5) then
NRT="Text is very clean."
ElseIf (NR<10) then
NRT="Text is relatively clean"
ElseIf (NR<15) then
NRT="Can use less noise."
ElseIf (NR<18) then
NRT="Somewhat noisy."
ElseIf (NR<20) then
NRT="Noisy. Very Noisy."
ElseIf (NR<23) then
NRT="You're being annoying on purpose, aren't you?"
ElseIf (NR<28) then
NRT="Are you kidding me? I have to wash my eyeballs after this!"
ElseIf (NR<32) then
NRT="Is there a World War out there? Gettouttahere!"
ElseIf (NR<50) then
NRT="This is so bad, I will not dignify it with a response!"
else
NRT="This high level of noise is impossible! Impossible!"
endif
TextWindow.WriteLine("")
TextWindow.Write("Noise ratio is ")
TextWindow.WriteLine(NR)
TextWindow.WriteLine(NRT)
endsub
Sub WriteText
TextWindow.BackgroundColor=WT[1]
TextWindow.ForegroundColor=WT[2]
TextWindow.Write(Word)
TextWindow.BackgroundColor="black"
TextWindow.ForegroundColor="white"
EndSub
Sub GetDictWord
If (HashWord[Word]="") Then
tword=Dictionary.GetDefinition(Word)
If (tword="") then
tword="Unknown. (unknown) "
EndIf
tline=Text.GetSubText(tword,1,1+Text.GetIndexOf(tword,")"))
HashWord[Word]=tline
EndIf
DictWord=HashWord[Word]
'TextWindow.WriteLine(DictWord)
EndSub
Sub WriteDictFile
FileDir=text.Append(Program.Directory,"\dict.txt")
File.WriteContents(FileDir,HashWord)
EndSub
Sub ReadDictFile
FileDir=text.Append(Program.Directory,"\dict.txt")
HashWord=File.ReadContents(FileDir)
EndSub
No comments:
Post a Comment