vinnyMS Posted September 30, 2020 Share Posted September 30, 2020 hi, i have a pseudo script ready and i need to complete it to make it a full program it's supposed to be a word frequency counter. the idea is based on an online Word Frequency Counter at https://www.browserling.com/tools/word-frequency #Region INCLUDE #include <GuiConstantsEx.au3> #EndRegion INCLUDE #Region GUI GUICreate("Word Frequency Count", 400, 420) GUISetIcon(@SystemDir & "\mstsc.exe", 0) #EndRegion GUI #Region EDIT GUICtrlCreateEdit(@CRLF & "", 10, 10, 370, 360) GUICtrlSetTip(-1, '#Region EDIT') #EndRegion EDIT #Region BUTTON GUICtrlCreateButton("Find frequency", 280, 375, 100, 30) GUICtrlSetTip(-1, '#Region BUTTON') #EndRegion BUTTON #Region GUI MESSAGE LOOP GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() #EndRegion GUI MESSAGE LOOP Link to comment Share on other sites More sharing options...
Nine Posted October 1, 2020 Share Posted October 1, 2020 Scripting dictionary... “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...
JockoDundee Posted October 1, 2020 Share Posted October 1, 2020 2 hours ago, vinnyMS said: i have a pseudo script ready and i need to complete it to make it a full program agreed. Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
abberration Posted October 1, 2020 Share Posted October 1, 2020 This is far from perfect (mostly, you need to work on getting rid of excess spaces), but it may give you some ideas: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <array.au3> #include <string.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 376) $Edit1 = GUICtrlCreateEdit("", 8, 24, 409, 289, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetData(-1, "Geology is an Earth science concerned with the solid Earth, the rocks of which it is composed, and the processes by which they change over time. ") $List1 = GUICtrlCreateList("", 440, 24, 161, 279) $Button1 = GUICtrlCreateButton("Go", 480, 336, 75, 25, $WS_GROUP) $Label1 = GUICtrlCreateLabel("Input Text", 8, 0, 52, 17) $Label2 = GUICtrlCreateLabel("Word Frequency", 440, 0, 83, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $sTextRead = GUICtrlRead($Edit1) _Frequency($sTextRead) EndSwitch WEnd Func _Frequency($sTextRead) $aStringToArray = StringSplit($sTextRead, " ") $aUniqueWords = _ArrayUnique($aStringToArray, 0, 1) For $i = 1 To $aUniqueWords[0] $aNumResults = _ArrayFindAll($aStringToArray, $aUniqueWords[$i]) $aUniqueWords[$i] &= " - " & UBound($aNumResults) GUICtrlSetData($List1, $aUniqueWords[$i]) Next EndFunc Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
mikell Posted October 1, 2020 Share Posted October 1, 2020 (edited) An other flavour... #Include <Array.au3> $s = "Geology is an Earth science concerned with the solid Earth, the rocks of which it is composed, and the processes by which they change over time." Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) _ArrayColInsert($w, 1) For $i = 0 to UBound($w)-1 StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) $w[$i][1] = @extended Next _ArraySort($w, 1, 0, 0, 1) _ArrayDisplay($w) Edited October 1, 2020 by mikell options... Link to comment Share on other sites More sharing options...
abberration Posted October 1, 2020 Share Posted October 1, 2020 @mikell That's what I love about AutoIt - there are so many ways to accomplish a task. I need to study your regex expressions a bit more to fully understand them, but your method is an interesting solution. Also, I didn't know about @extended - I learned something new today. Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
mikell Posted October 2, 2020 Share Posted October 2, 2020 @abberration The regex is for fun and not a difficult one, the important thing inside is the use of \b (word boundary) so "the" is not matched in "they" The @extended feature of StringReplace and SRER is pretty useful indeed to get a number of replacements/occurences BTW depending on which characters "words" may contain, your solution can be better - or the regex needs modifications abberration 1 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