vinnyMS Posted July 20, 2021 Share Posted July 20, 2021 i have a word frequency counter script. the problem is that it counts 1 letter words and numbers i need the script to list only 2 or more letter words with no numbers #Include <Array.au3> #Include <Debug.au3> #include <Constants.au3> #include <AutoItConstants.au3> Example() Func Example() $s = FileRead("2.txt") ProgressOn ( "Word Frequency", "Counting", "Loading", Default, Default, 18 ) Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) _ArrayColInsert($w, 1) For $i = 0 to UBound($w)-1 ProgressSet (( $i/(UBound($w) - 1)) * 100, "processed", "word frequency" ) StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) $w[$i][1] = @extended Next ProgressSet(100, "Done", "Complete") _ArraySort($w, 1, 0, 0, 1) _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) ; _DebugArrayDisplay($w, "Title", "|0:1") ; _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) $sMessage = "" SplashTextOn("Counting words", $sMessage, -1, -1, -1, -1, $DLG_TEXTLEFT, "") For $i = 1 To $w $sMessage = $sMessage & $i & @CRLF Next ProgressOff() EndFunc ;==>Example Link to comment Share on other sites More sharing options...
Solution Nine Posted July 20, 2021 Solution Share Posted July 20, 2021 Try this pattern : Local $w = StringRegExp($s, "(?s)(\b[[:alpha:]]{2,}\b)", 3) JockoDundee 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now