vinnyMS Posted July 20, 2021 Share Posted July 20, 2021 i have a script that counts the word frequency and displays it in an array table i need it to write the results in a text file instead of an array table here's the script #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, "(?s)(\b[[:alpha:]]{2,}\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 0 $sMessage = $sMessage & $i & @CRLF Next ProgressOff() EndFunc ;==>Example Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 20, 2021 Moderators Share Posted July 20, 2021 So look at FileWrite/FileWriteLine/_FileWriteFromArray in the help file? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Nine Posted July 20, 2021 Share Posted July 20, 2021 BTW, my pattern was not complete, I thought you would see that. Anyway, for completeness to anyone looking at it : Local $w = StringRegExp($s, '(*UCP)(?is)(\b[[:alpha:]]{2,}\b)(?!.*\b\1\b)', 3) “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...
vinnyMS Posted July 20, 2021 Author Share Posted July 20, 2021 1 hour ago, JLogan3o13 said: So look at FileWrite/FileWriteLine/_FileWriteFromArray in the help file? Sorry to bother, I'm not a programmer so it's very difficult to create to me. It requires a lot of edits. Plz help Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 20, 2021 Moderators Share Posted July 20, 2021 @vinnyMS This forum is dedicated to people who want to learn/improve at AutoIt scripting; it is not a place where you put in an order and someone just barfs up the code for you. If we did that, you'd never understand when you ran into a problem, or attempted to update the code Take a look at the sections I suggested in the help file. Each has great examples that you can try out on your own. Once you have done so, if you're running into issues, post what you have tried and we will gladly steer you in the right direction. TheDcoder 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
TheDcoder Posted July 21, 2021 Share Posted July 21, 2021 4 hours ago, vinnyMS said: I'm not a programmer so it's very difficult to create to me. It requires a lot of edits. Why not use a program to do the counting? I am sure there are many available. But if you are doing this to learn programming then you should indeed follow JLogan's advice and start learning the language, you can use the help file and maybe some youtube videos EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
leuce Posted July 21, 2021 Share Posted July 21, 2021 (edited) 14 hours ago, vinnyMS said: I have a script that counts the word frequency and displays it in an array table. Where did you get that script from? (-: Quote I need it to write the results in a text file instead of an array table. I'm not a programmer either, so how about this: #Include <Array.au3> $s = FileRead ("2.txt") Local $w = StringRegExp ($s, "(?s)(\b[[:alpha:]]{2,}\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) $z1 = _ArrayToString ($w, @TAB, -1, -1, @CRLF, -1, -1) FileWrite ("2_output1.txt", $z1) $z2 = StringSplit ($z1, @CRLF, 1) $z3 = _ArrayUnique ($z2) $z4 = _ArrayToString ($z3, @CRLF) FileWrite ("2_output2.txt", $z4) (which is basically your script, with some stuff removed and some stuff added.) Edited July 21, 2021 by leuce Link to comment Share on other sites More sharing options...
Earthshine Posted July 21, 2021 Share Posted July 21, 2021 (edited) is this a homework question? 😀 (i had this assignment in pascal in college... lol) Edited July 21, 2021 by Earthshine JockoDundee, TheDcoder and SkysLastChance 3 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
vinnyMS Posted July 21, 2021 Author Share Posted July 21, 2021 10 hours ago, Earthshine said: is this a homework question? 😀 (i had this assignment in pascal in college... lol) it's for reading EEG in plain text Link to comment Share on other sites More sharing options...
JockoDundee Posted July 21, 2021 Share Posted July 21, 2021 12 hours ago, Earthshine said: is this a homework question? Not the first time VinnyMS has been hit with such an allegation TheDcoder 1 Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
TheDcoder Posted July 21, 2021 Share Posted July 21, 2021 I hate homework and interview coding, there isn't much of a difference between both, they want some arbitrary twisted thing done instead of something practical. If I was good at those I would be doing math or spell bee competitions JockoDundee 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
vinnyMS Posted July 22, 2021 Author Share Posted July 22, 2021 1 hour ago, JockoDundee said: Not the first time VinnyMS has been hit with such an allegation Not exactly homework That script was to use to extract text from hundreds of files and create a text list based on file content. Then the text extracted was to be replaced with text in another language. Extracted as Chinese and replaced by English. This way I could translate all those files by replacing the text from Chinese to English This other script is to create lists of top frequency to again replace from numbers to words. I work a lot with text file editing. I have all sort of ideas about programs Link to comment Share on other sites More sharing options...
JockoDundee Posted July 22, 2021 Share Posted July 22, 2021 1 hour ago, vinnyMS said: Not exactly homework Come on, Vinny, ya know I’m just messin’ with ya! That post was from before we really got started cranking out the hits. But by the end of the semester, we was all good, right? TheDcoder and SkysLastChance 2 Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
vinnyMS Posted July 22, 2021 Author Share Posted July 22, 2021 Cool w me Greetings Link to comment Share on other sites More sharing options...
leuce Posted July 22, 2021 Share Posted July 22, 2021 On 7/20/2021 at 10:11 PM, vinnyMS said: I have a script that counts the word frequency and displays it in an array table. I need it to write the results in a text file instead of an array table. and 10 hours ago, vinnyMS said: It's for reading EEG in plain text. Okay... erm... err... no, I don't see how you get from post #1 to post #2. Link to comment Share on other sites More sharing options...
vinnyMS Posted July 22, 2021 Author Share Posted July 22, 2021 post 1 is to create two lists, the before list and the after list 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