Search the Community
Showing results for tags 'Dictionary'.
-
-
-
Can someone please say me what i'm missing here? this little problem is driving me crazy! i feel so stupid that i have to ask this but why does this script thinks that "=" doesn't exist inside the dictionary? $regex = ObjCreate("VBScript.RegExp") $regex.Pattern = "=" $regex.Global = True $regex.IgnoreCase = True $test = ObjCreate("scripting.dictionary") $test.add("=", 2) $sentence = "=" Local $find = $regex.execute($sentence) for $part in $find msgbox(0,1,$part.Value) MsgBox(0,2,$part.Value = "=") MsgBox(0,3,$test.exists("=")) msgbox(0,4,$test.exists($part)) ;this should be true! next Thanks for any help TheAutomator.
- 4 replies
-
- regex
- dictionary
-
(and 1 more)
Tagged with:
-
Hello, I would like to know, how can I add any unknown word into Ms Word 2010's custom dictionary via Word COM Object? As we can do by selecting "Add to dictionary" option from context menu of Word. Thanks.
- 4 replies
-
- word
- dictionary
-
(and 1 more)
Tagged with:
-
If you don't like dealing with Scripting.dictionary you might want to try out this thing I whipped up yesterday evening and this morning. Basically just a simple wrapper around Scripting.dictionary to make the API a little bit less stupid. By "stupid" I mean "not like the awesome Python dict API". Created for the following reasons.. Wanted to get a basic understanding of AutoItObject. Wanted to get a basic understanding of the Micro unit test framework. As of 11/4/2014 AutoIt Stable has no native dict or associative array type. A >Map type is in the current AutoIt beta. It's laborious to use Scripting.dictionary all the time. The Python dict API is better than Scripting.dictionary's I thought about writing my own hash table implementation in AutoIt, but on balance I decided it wasn't worth the effort and just stuck to Scripting.dictionary to save time/effort. As you can see I've got a decent number of unit tests for such a simple implementation, so it should be quite robust. #include <Dict2.au3> #include <Array.au3> $dict = _DictCreate() ConsoleWrite($dict.len()) ; Outputs 0 $dict.set("key1", "value1") $dict.set("key2", "value2") $dict.set("key3", "value3") $dict.set("key4", 1) ConsoleWrite($dict.get("key2")) ; Outputs 'value2' ConsoleWrite($dict.len()) ; Outputs 3 ConsoleWrite($dict.contains("key2") ; Outputs True $dict.set("key4", $dict.get("key4") + 1) ConsoleWrite($dict.get("key4")) ; Outputs 2 $dict.del("key4") ConsoleWrite($dict.contains("key4")) ; Outputs False $aPairs = $dict.pairs() _ArrayDisplay($aPairs) ; Displays 2d array with column one contains keys, and column two ; containing associated values $aKeys = $dict.keys() _ArrayDisplay($aKeys) ; Displays array containing all keys $aValues = $dict.values() _ArrayDisplay($aValues) ; Displays array of all values $aDesiredKeys = ["key1", "key3"] $aValues = $dict.values($aDesiredKeys) _ArrayDisplay($aValues) ; Displays array of values for key1 and key3 GET IT HERE
- 3 replies
-
- dictionary
- associative array
-
(and 2 more)
Tagged with:
-
Is there a way to share a Scripting.Dictionary object between scripts? I was thinking this would be possible with COM, but I'm not familiar enough with it to do so... Or is there a better way to share objects between programs? What about sharing arrays?
- 2 replies
-
- Scripting.Dictionary
- COM
-
(and 3 more)
Tagged with:
-
Here are Twotoo stupid scripts, You need the attached wordlist file for it to work. I only tested with autoit3 beta and XP. I was just playing around with things that could be done with a wordlist. I might make some games with a wordlist, but this one just has too many words that are uncommon. You need this word dictionary http://www.filefactory.com/file/1y14t7tazsun/n/Words_sqlite I generated the word dictionary from moby word list. The first script is a mad-lib generator, the second is a random sentence generators. It made me giggle like a school girl in heat, so I though I would share. The attachment will expire after seven days of inactivity, so let me know if it needs to be re-upped. #include <file.au3> #include<array.au3> #include <SQLite.au3> #include <SQLite.dll.au3> $sWordlist="mobypos.txt" #region -word types ;~ Interjection ! ;~ Adjective A ;~ Conjunction C ;~ Definite Article D ;~ Noun Phrase h ;~ Verb (intransitive) i ;~ Indefinite Article I ;~ Noun N ;~ Nominative o ;~ Plural p ;~ Preposition P ;~ Pronoun r ;~ Verb (transitive) t ;~ Verb (usu participle) V ;~ Adverb v #endregion _SQLite_Startup() _SQLite_Open("Words.sqlite") global $gsText="Then God spoke all these words, saying, “I am the LORD your God, who brought you out of the land of Egypt, out of the house of slavery. “You shall have no other gods before Me. “You shall not make for yourself an idol, or any likeness of what is in heaven above or on the earth beneath or in the water under the earth. You shall not worship them or serve them; for I, the LORD your God, am a jealous God, visiting the iniquity of the fathers on the children, on the third and the fourth generations of those who hate Me, but showing lovingkindness to thousands, to those who love Me and keep My commandments. “You shall not take the name of the LORD your God in vain, for the LORD will not leave him unpunished who takes His name in vain. “Remember the sabbath day, to keep it holy. Six days you shall labor and do all your work, but the seventh day is a sabbath of the LORD your God; in it you shall not do any work, you or your son or your daughter, your male or your female servant or your cattle or your sojourner who stays with you. For in six days the LORD made the heavens and the earth, the sea and all that is in them, and rested on the seventh day; therefore the LORD blessed the sabbath day and made it holy. “Honor your father and your mother, that your days may be prolonged in the land which the LORD your God gives you. “You shall not murder. “You shall not commit adultery. “You shall not steal. “You shall not bear false witness against your neighbor. “You shall not covet your neighbor’s house; you shall not covet your neighbor’s wife or his male servant or his female servant or his ox or his donkey or anything that belongs to your neighbor.”" global $gsWord global $giSillinesFactor=30 ;less = more silly _SQLite_Exec(-1,"PRAGMA case_sensitive_like=1") Local $gsFinal $gaText=StringSplit($gsText, " ") for $x=1 to StringLen($gsText)/$giSillinesFactor $y=random(1,$gaText[0],1) _SQLite_Exec(-1, 'select type from tblwords where word= "'&$gaText[$y]&'"',"_cb") $gsOldWord= $gaText[$y] if $gsWord<>"" then _SQLite_Exec(-1, 'select word from tblwords where type like "'&$gsWord&'" ORDER BY RANDOM() LIMIT 1',"_cb") if $gsWord=$gsOldWord then ContinueLoop $gaText[$y]=$gsWord EndIf Next for $x=1 to $gaText[0] $gsFinal&=$gaText[$x]&" " Next MsgBox(0,"",$gsFinal) Func _cb($aRow) For $s In $aRow $gsWord=$s Next EndFunc _SQLite_Close() _SQLite_Shutdown() #include <file.au3> #include<array.au3> #include <SQLite.au3> #include <SQLite.dll.au3> ;~ $sWordlist="mobypos.txt" #region -word types ;~ Interjection ! ;~ Adjective A ;~ Conjunction C ;~ Definite Article D ;~ Noun Phrase h ;~ Verb (intransitive) i ;~ Indefinite Article I ;~ Noun N ;~ Nominative o ;~ Plural p ;~ Preposition P ;~ Pronoun r ;~ Verb (transitive) t ;~ Verb (usu participle) V ;~ Adverb v #endregion _SQLite_Startup() _SQLite_Open("Words.sqlite") Global $gsRandomReturn global $gsNounPhase global $gxPluralSwitch=False Global $gsAdjetiveRandomness=.5 global $gsPostNounModifierRandomness=.9 global $gsAdverbRanomness=.9 _SQLite_Exec(-1,"PRAGMA case_sensitive_like=1") _SQLite_Exec(-1, 'select * from tblwords where word like "run" ',"_cb") _CreateSentenceType() func _CreateSentenceType() _createnounphrase() ;~ _createVerbPhrase() EndFunc Func _createnounphrase() _PickNounPhrase() EndFunc Func _PickNounPhrase() _SQLite_Exec(-1, 'select word from tblwords where type like "%D%" ORDER BY RANDOM() LIMIT 1;',"_SetArticlePhrase") while random(0,1)<$gsAdjetiveRandomness _SQLite_Exec(-1, 'select word from tblwords where type like "%A%" ORDER BY RANDOM() LIMIT 1;',"_SetPhrase") WEnd if $gxPluralSwitch=false then _SQLite_Exec(-1, 'select word from tblwords where type like "%h%" OR type like "%N%" ORDER BY RANDOM() LIMIT 1;',"_SetPhrase") else _SQLite_Exec(-1, 'select word from tblwords where type like "%p%" ORDER BY RANDOM() LIMIT 1;',"_SetPhrase") EndIf if random(0,1)<$gsPostNounModifierRandomness then _SQLite_Exec(-1, 'select word from tblwords where type like "%P%" ORDER BY RANDOM() LIMIT 1;',"_SetPhrase") _SQLite_Exec(-1, 'select word from tblwords where type like "%N%" ORDER BY RANDOM() LIMIT 1;',"_SetPhrase") EndIf _SQLite_Exec(-1, 'select word from tblwords where type like "%V%" ORDER BY RANDOM() LIMIT 1;',"_SetPhrase") if random(0,1)<$gsAdverbRanomness then _SQLite_Exec(-1, 'select word from tblwords where type like "%v%" ORDER BY RANDOM() LIMIT 1;',"_SetPhrase") MsgBox(0,"Warning!",$gsNounPhase) EndFunc func _SetArticlePhrase($aRow) For $s In $aRow $gsNounPhase&=$s & " " Switch $s case "One","The","a","an", "that", "each" $gxPluralSwitch=False case "my", "his" , "her", "their", "what" if random(0,1,1)=1 Then $gxPluralSwitch=True Else $gxPluralSwitch=False EndIf case Else $gxPluralSwitch=True EndSwitch Next EndFunc func _SetPhrase($aRow) For $s In $aRow $gsNounPhase&=$s & " " Next EndFunc _SQLite_Close() _SQLite_Shutdown() Here is an example from the mad-lib generator Here is an example from the random phrase generator.