 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Guest_AutoHotkey_L Guest
|
Posted: Sat Jun 26, 2010 3:43 am Post subject: |
|
|
At:
http://www.autohotkey.net/~Tuncay/ini/ini.html#ini_getAllValues
(and in the source I have here) I currently see both:
| Quote: | Returns
On success a comma separated list with all name of keys is returned, otherwise an empty string.
| and
| Quote: | Remarks
Other than the other getAll-functions list separator, this function uses the new line “`n” character instead the comma “,” for separating values.
|
I presume the Remarks section is correct. Does that seem right? Or perhaps I have misunderstood something. |
|
| Back to top |
|
 |
Tuncay not logged in Guest
|
Posted: Fri Jul 02, 2010 8:57 am Post subject: |
|
|
Yes thats right. Normally I used the comma separated to separate the items. That time, I was reading different specifications about the ini format and different implementations. To me it was sure enough to use the comma. I do not think any section or key name would contain a comma. All other functions are based on this specification. So there is no need for a change at this topic.
Later, I added the function getAllValues(). A value can contain nearly any character and this would be a problem. The only one character which cannot contain is the new line character. Because the newline ends the value.
So it is correct.  |
|
| Back to top |
|
 |
Tuncay not logged in Guest
|
Posted: Fri Jul 02, 2010 9:00 am Post subject: uuuuuuuuuuuuupssss |
|
|
OH sorry, I did not see the copy and paste error!
Yes you are right. Sorry for the confusion. new line is used, and the text at Returns is not correct. I forgot after pasting the text to edit it. Thx for reporting that. |
|
| Back to top |
|
 |
tidbit
Joined: 09 Mar 2008 Posts: 1808 Location: Minnesota, USA
|
Posted: Tue Sep 21, 2010 7:46 pm Post subject: |
|
|
Great function.
How would I go about speeding up ini_insertvalue()?
i have a list of over 200,000 words hat I need organized and after 8k it gets slow. takes about 30 minutes for the whole thing.
i tried adding VarSetCapacity(_Content, 10240000) (10Mb) to the function and well, it only takes 3 minutes, great! however, it then erases the contents of _Content.
from what I was told, if i figured out a way to use _Content.= insted of _Content:= VarSetCapacity() should work. and then it would greatly increase the speed.
only issue, i have no clue how!
any help? thanks! _________________ rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
Even monkeys fall from trees. - Japanese proverb |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
Posted: Tue Sep 21, 2010 8:27 pm Post subject: |
|
|
Thanks tdibit.
The library is not designed and tested for use with large data. At every call of ini_insertValue() the whole content is replaced with inserted content. There is not much room for optimizing the function.
But if you need to call the function many times, I would recommend to set PreserveSpace parameter to true.
Add SetBatchLines, -1 to your script before calling this function.
Can you avoid so many calls of ini_insertValue()? If it is possible, I strongly encourage you to add the data into a variable. And after your variable is constructed, then update the ini content once with the ini_insertValue() function.
Another suggestion is, if you operate on large ini file, work on one section only, instead of whole content. Extract the section ini_getSection() and after work is done, update the section in orginal data with ini_replaceSection().
... to speed up the function itself, I do not have any idea yet. The whole library is designed for Vanilla Ahk. And generally said, Vanilla Ahk is faster in my tests than AHK_L.
Current code of function ini_insertValue():
| Code: | ini_insertValue(ByRef _Content, _Section, _Key, _Value, _PreserveSpace = False)
{
If (_Section = "")
_Section = (?:\[.*])?
Else
_Section = \[\s*?\Q%_Section%\E\s*?]
If Not _PreserveSpace
{
_Value = %_Value% ; Trim spaces.
FirstChar := SubStr(_Value, 1, 1)
If (FirstChar = """" AND SubStr(_Value, 0, 1)= """"
OR FirstChar = "'" AND SubStr(_Value, 0, 1)= "'")
{
StringTrimLeft, _Value, _Value, 1
StringTrimRight, _Value, _Value, 1
}
}
; Note: The regex of this function was written by Mystiq.
RegEx = S`aiU)((?:\R|^)\s*%_Section%\s*(?:\R\s*|\R\s*.+\s*=\s*.*?\s*(?=\R)|\R\s*[;#].*?(?=\R))*\R\s*\Q%_Key%\E\s*=.*?)((?=\R|$))
_Content := RegExReplace(_Content, RegEx, "$1" . _Value . "$2", isInserted, 1)
If isInserted
ErrorLevel = 0
Else
ErrorLevel = 1
Return isInserted
} |
_________________ {1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <-- |
|
| Back to top |
|
 |
tidbit
Joined: 09 Mar 2008 Posts: 1808 Location: Minnesota, USA
|
Posted: Tue Sep 21, 2010 8:39 pm Post subject: |
|
|
1) i'm using the main AHK.
2) the text is in a .txt file loaded into ahk with fileread.
3) the contents is on new-lines and tab delimited.
-- i write the first word according to the value of the second word (word1 %A_tab% word2)
4) I write word 1 to the appropriate key based on word2
5) i can not pre-organize it.
what i'm trying to do is organize a dictionary based on part-of-speech.
here is my code as of now:
| Code: | #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#singleInstance force
SetBatchLines, -1
SetWinDelay, -1
fileread, list1, %A_ScriptDir%\pos\pos.txt
fileread, list2, %A_ScriptDir%\cl.txt
FileDelete, %A_ScriptDir%\data.ini
ini_load(ini, A_scriptdir "\data2.ini")
start:=a_tickcount
loop, parse, list1, `n, `r
{
;RegExMatch(A_loopField, "S)(.*)\t(.*)", word)
StringSplit, word, A_loopField, %A_tab%
letter:=SubStr(word1, 1,1)
ToolTip %word1%`n%a_index%
;if (InStr(list2, word1))
;{
if (word2=="N")
{
ini_insertvalue(ini, letter, "Noun", word1 ",")
Continue
}
if (word2=="P")
{
ini_insertvalue(ini, letter, "Plural", word1 ",")
Continue
}
if (word2=="h")
{
ini_insertvalue(ini, letter, "NounPhrase", word1 ",")
Continue
}
if (word2=="V")
{
ini_insertvalue(ini, letter, "particVerb", word1 ",")
Continue
}
if (word2=="t")
{
ini_insertvalue(ini, letter, "transVerb", word1 ",")
Continue
}
if (word2=="i")
{
ini_insertvalue(ini, letter, "intVerb", word1 ",")
Continue
}
if (word2=="A")
{
ini_insertvalue(ini, letter, "Adjective", word1 ",")
Continue
}
if (word2=="v")
{
ini_insertvalue(ini, letter, "Adverb", word1 ",")
Continue
}
if (word2=="C")
{
ini_insertvalue(ini, letter, "Conjunction", word1 ",")
Continue
}
if (word2=="P")
{
ini_insertvalue(ini, letter, "Preposition", word1 ",")
Continue
}
if (word2=="!")
{
ini_insertvalue(ini, letter, "Interjection", word1 ",")
Continue
}
if (word2=="r")
{
ini_insertvalue(ini, letter, "Pronoun", word1 ",")
Continue
}
if (word2=="D")
{
ini_insertvalue(ini, letter, "DefArticle", word1 ",")
Continue
}
if (word2=="I")
{
ini_insertvalue(ini, letter, "IndefArticle", word1 ",")
Continue
}
if (word2=="o")
{
ini_insertvalue(ini, letter, "Nominative", word1 ",")
Continue
}
sleep, -1
continue
;}
;Else
;Continue
}
ini_save(ini)
msgbox % "done " ((a_tickcount-start)/1000)/60
exitapp
Return
esc::
ini_save(ini)
ExitApp |
here is the ini layout:
| Code: | # N Noun
# P Plural
# h Noun Phrase
# V particVerb (usu participle)
# t transVerb (transitive)
# i intVerb (intransitive)
# A Adjective
# v Adverb
# C Conjunction
# P Preposition
# ! Interjection
# r Pronoun
# D DefArticle definite
# I IndefArticle indefinate
# o Nominative
[A]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[B]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[C]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[D]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[E]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[F]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[G]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[H]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[I]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[J]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[K]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[L]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[M]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[N]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[O]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[P]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[Q]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[R]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[S]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[T]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[U]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[V]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[W]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[X]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[Y]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
[Z]
Noun=
Plural=
NounPhrase=
particVerb=
transVerb=
intVerb=
Adjective=
Adverb=
Conjunction=
Preposition=
Interjection=
Pronoun=
DefArticle=
IndefArticle=
Nominative=
|
here is a dictionary sample:
| Code: | Outsped T
Coverall N
Febe N
Crabeating N
Outwearying T
Preutilized T
Iter N
Californite N
Nonsubliminal A
Galbraith N
Ammonified V
Hydropic A
Outcall V
Aiello N
Papillar A
Handworked A
Lackey N
Metempsychic A |
_________________ rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
Even monkeys fall from trees. - Japanese proverb |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
Posted: Tue Sep 21, 2010 9:28 pm Post subject: |
|
|
1. Where are your elses?
2. Try VarSetCapacity() your variable before Loop begins.
3. Set PreserveSpace to true.
| Code: | #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#singleInstance force
SetBatchLines, -1
SetWinDelay, -1
fileread, list1, %A_ScriptDir%\pos\pos.txt
fileread, list2, %A_ScriptDir%\cl.txt
FileDelete, %A_ScriptDir%\data.ini
VarSetCapacity(ini, 10240000)
ini_load(ini, A_scriptdir "\data2.ini")
start:=a_tickcount
loop, parse, list1, `n, `r
{
;RegExMatch(A_loopField, "S)(.*)\t(.*)", word)
StringSplit, word, A_loopField, %A_tab%
letter:=SubStr(word1, 1,1)
ToolTip %word1%`n%a_index%
;if (InStr(list2, word1))
;{
if (word2=="N")
{
ini_insertvalue(ini, letter, "Noun", word1 ",", true)
}
else if (word2=="P")
{
ini_insertvalue(ini, letter, "Plural", word1 ",", true)
}
else if (word2=="h")
{
ini_insertvalue(ini, letter, "NounPhrase", word1 ",", true)
}
else if (word2=="V")
{
ini_insertvalue(ini, letter, "particVerb", word1 ",", true)
}
else if (word2=="t")
{
ini_insertvalue(ini, letter, "transVerb", word1 ",", true)
}
else if (word2=="i")
{
ini_insertvalue(ini, letter, "intVerb", word1 ",", true)
}
else if (word2=="A")
{
ini_insertvalue(ini, letter, "Adjective", word1 ",", true)
}
else if (word2=="v")
{
ini_insertvalue(ini, letter, "Adverb", word1 ",", true)
}
else if (word2=="C")
{
ini_insertvalue(ini, letter, "Conjunction", word1 ",", true)
}
else if (word2=="P")
{
ini_insertvalue(ini, letter, "Preposition", word1 ",", true)
}
else if (word2=="!")
{
ini_insertvalue(ini, letter, "Interjection", word1 ",", true)
}
else if (word2=="r")
{
ini_insertvalue(ini, letter, "Pronoun", word1 ",", true)
}
else if (word2=="D")
{
ini_insertvalue(ini, letter, "DefArticle", word1 ",", true)
}
else if (word2=="I")
{
ini_insertvalue(ini, letter, "IndefArticle", word1 ",", true)
}
else if (word2=="o")
{
ini_insertvalue(ini, letter, "Nominative", word1 ",", true)
}
sleep, -1
continue
;}
;Else
;Continue
}
ini_save(ini)
msgbox % "done " ((a_tickcount-start)/1000)/60
exitapp
Return
esc::
ini_save(ini)
ExitApp
|
CODES NOT TESTED! _________________ {1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <-- |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
Posted: Tue Sep 21, 2010 9:32 pm Post subject: |
|
|
Here is an alternative way what I was talking about:
| Code: | #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#singleInstance force
SetBatchLines, -1
SetWinDelay, -1
fileread, list1, %A_ScriptDir%\pos\pos.txt
fileread, list2, %A_ScriptDir%\cl.txt
FileDelete, %A_ScriptDir%\data.ini
VarSetCapacity(ini, 10240000)
ini_load(ini, A_scriptdir "\data2.ini")
start:=a_tickcount
loop, parse, list1, `n, `r
{
;RegExMatch(A_loopField, "S)(.*)\t(.*)", word)
StringSplit, word, A_loopField, %A_tab%
letter:=SubStr(word1, 1,1)
ToolTip %word1%`n%a_index%
;if (InStr(list2, word1))
;{
if (word2=="N")
{
ini_%letter%_Noun .= word1 ","
}
else if (word2=="P")
{
ini_%letter%_Plural .= word1 ","
}
else if (word2=="h")
{
ini_%letter%_NounPhrase .= word1 ","
}
else if (word2=="V")
{
ini_%letter%_particVerb .= word1 ","
}
else if (word2=="t")
{
ini_%letter%_transVerb .= word1 ","
}
else if (word2=="i")
{
ini_%letter%_intVerb .= word1 ","
}
else if (word2=="A")
{
ini_%letter%_Adjective .= word1 ","
}
else if (word2=="v")
{
ini_%letter%_Adverb .= word1 ","
}
else if (word2=="C")
{
ini_%letter%_Conjunction .= word1 ","
}
else if (word2=="P")
{
ini_%letter%_Preposition .= word1 ","
}
else if (word2=="!")
{
ini_%letter%_Interjection .= word1 ","
}
else if (word2=="r")
{
ini_%letter%_Pronoun .= word1 ","
}
else if (word2=="D")
{
ini_%letter%_DefArticle .= word1 ","
}
else if (word2=="I")
{
ini_%letter%_IndefArticle .= word1 ","
}
else if (word2=="o")
{
ini_%letter%_Nominative .= word1 ","
}
sleep, -1
continue
;}
;Else
;Continue
}
letters := "abcdefghijklmnopqrstuvwxyz"
Loop, Parse
{
ini_insertvalue(ini, "N", "Noun", ini_%A_LoopField%_Noun)
ini_insertvalue(ini, "p", "Plural", ini_%A_LoopField%_Plural)
ini_insertvalue(ini, "h", "NounPhrase", ini_%A_LoopField%_NounPhrase)
ini_insertvalue(ini, "V", "particVerb", ini_%A_LoopField%_particVerb)
ini_insertvalue(ini, "t", "transVerb", ini_%A_LoopField%_transVerb)
ini_insertvalue(ini, "i", "intVerb", ini_%A_LoopField%_intVerb)
ini_insertvalue(ini, "a", "Adjective", ini_%A_LoopField%_Adjective)
ini_insertvalue(ini, "v", "Adverb", ini_%A_LoopField%_Adverb)
ini_insertvalue(ini, "C", "Conjunction", ini_%A_LoopField%_Conjunction)
ini_insertvalue(ini, "P", "Preposition", ini_%A_LoopField%_Preposition)
ini_insertvalue(ini, "!", "Interjection", ini_%A_LoopField%_Interjection)
ini_insertvalue(ini, "r", "Pronoun", ini_%A_LoopField%_Pronoun)
ini_insertvalue(ini, "D", "DefArticle", ini_%A_LoopField%_DefArticle)
ini_insertvalue(ini, "I", "IndefArticle", ini_%A_LoopField%_IndefArticle)
ini_insertvalue(ini, "o", "Nominative", ini_%A_LoopField%_Nominative)
}
ini_save(ini)
msgbox % "done " ((a_tickcount-start)/1000)/60
exitapp
Return
esc::
ini_save(ini)
ExitApp |
_________________ {1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <-- |
|
| Back to top |
|
 |
tidbit
Joined: 09 Mar 2008 Posts: 1808 Location: Minnesota, USA
|
Posted: Tue Sep 21, 2010 9:56 pm Post subject: |
|
|
else isn't needed since the Continues skip everything else.
first script is slow.
second script is fast and good! only issue: it doesnt write to the ini.
I would also like to preserve my format, not ini_insertvalue(ini, "N", "Noun", ini_%A_LoopField%_Noun).
edit: nevermind. it works with some light modification  _________________ rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
Even monkeys fall from trees. - Japanese proverb |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
Posted: Tue Sep 21, 2010 10:13 pm Post subject: |
|
|
| Quote: | | else isn't needed since the Continues skip everything else. |
Ah yes. Correct.
| Quote: | | first script is slow. |
Do you mean slower than yours or still too slow?
| Quote: | | second script is fast and good! only issue: it doesnt write to the ini. |
Does msgbox Shows that the ini is correctly builded? ah you did not specified a path with ini_save()!
ini_load() returns full path of the ini. Use this variable for ini_save() to be sure it is the same file. i.g.:
| Code: | path := ini_load(ini, A_scriptdir "\data2.ini")
ini_save(ini, path) |
| Quote: | | I would also like to preserve my format, not ini_insertvalue(ini, "N", "Noun", ini_%A_LoopField%_Noun). |
What do you mean with that? About which format do you speak here?
Edit: Saw your edit too late.^^ What speed is shown now? Just curious... _________________ {1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <-- |
|
| Back to top |
|
 |
tidbit
Joined: 09 Mar 2008 Posts: 1808 Location: Minnesota, USA
|
Posted: Tue Sep 21, 2010 10:19 pm Post subject: |
|
|
heres the working code. it takes 4.5 minutes. pretty good.
| Code: | #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#singleInstance force
SetBatchLines, -1
SetWinDelay, -1
fileread, list1, %A_ScriptDir%\pos\pos_random.txt
fileread, list2, %A_ScriptDir%\cl.txt
FileDelete, %A_ScriptDir%\data.ini
VarSetCapacity(ini, 10240000)
ini_load(ini, A_scriptdir "\data2.ini")
start:=a_tickcount
loop, parse, list1, `n, `r
{
;RegExMatch(A_loopField, "S)(.*)\t(.*)", word)
StringSplit, word, A_loopField, %A_tab%
letter:=SubStr(word1, 1,1)
ToolTip %word1%`n%a_index%
;if (InStr(list2, word1))
;{
if (word2=="N")
{
ini_%letter%_Noun .= word1 ","
}
else if (word2=="P")
{
ini_%letter%_Plural .= word1 ","
}
else if (word2=="h")
{
ini_%letter%_NounPhrase .= word1 ","
}
else if (word2=="V")
{
ini_%letter%_particVerb .= word1 ","
}
else if (word2=="t")
{
ini_%letter%_transVerb .= word1 ","
}
else if (word2=="i")
{
ini_%letter%_intVerb .= word1 ","
}
else if (word2=="A")
{
ini_%letter%_Adjective .= word1 ","
}
else if (word2=="v")
{
ini_%letter%_Adverb .= word1 ","
}
else if (word2=="C")
{
ini_%letter%_Conjunction .= word1 ","
}
else if (word2=="P")
{
ini_%letter%_Preposition .= word1 ","
}
else if (word2=="!")
{
ini_%letter%_Interjection .= word1 ","
}
else if (word2=="r")
{
ini_%letter%_Pronoun .= word1 ","
}
else if (word2=="D")
{
ini_%letter%_DefArticle .= word1 ","
}
else if (word2=="I")
{
ini_%letter%_IndefArticle .= word1 ","
}
else if (word2=="o")
{
ini_%letter%_Nominative .= word1 ","
}
sleep, -1
continue
;}
;Else
;Continue
}
letters := "abcdefghijklmnopqrstuvwxyz"
Loop, Parse, letters
{
ini_insertvalue(ini, A_LoopField, "Noun", ini_%A_LoopField%_Noun)
ini_insertvalue(ini, A_LoopField, "Plural", ini_%A_LoopField%_Plural)
ini_insertvalue(ini, A_LoopField, "NounPhrase", ini_%A_LoopField%_NounPhrase)
ini_insertvalue(ini, A_LoopField, "particVerb", ini_%A_LoopField%_particVerb)
ini_insertvalue(ini, A_Loopfield, "transVerb", ini_%A_LoopField%_transVerb)
ini_insertvalue(ini, A_Loopfield, "intVerb", ini_%A_LoopField%_intVerb)
ini_insertvalue(ini, A_Loopfield, "Adjective", ini_%A_LoopField%_Adjective)
ini_insertvalue(ini, A_Loopfield, "Adverb", ini_%A_LoopField%_Adverb)
ini_insertvalue(ini, A_Loopfield, "Conjunction", ini_%A_LoopField%_Conjunction)
ini_insertvalue(ini, A_Loopfield, "Preposition", ini_%A_LoopField%_Preposition)
ini_insertvalue(ini, A_Loopfield, "Interjection", ini_%A_LoopField%_Interjection)
ini_insertvalue(ini, A_Loopfield, "Pronoun", ini_%A_LoopField%_Pronoun)
ini_insertvalue(ini, A_Loopfield, "DefArticle", ini_%A_LoopField%_DefArticle)
ini_insertvalue(ini, A_Loopfield, "IndefArticle", ini_%A_LoopField%_IndefArticle)
ini_insertvalue(ini, A_Loopfield, "Nominative", ini_%A_LoopField%_Nominative)
ToolTip %A_index%
}
ini_save(ini)
msgbox % "done " ((a_tickcount-start)/1000)/60
exitapp
Return
esc::
ini_save(ini)
ExitApp |
1) I meant it is as slow as mine.
2) it produced a blank file. though I pressed ESC. that skipped the last writing loop.
3) your format didn't preserve my [a] noun= ... [b] noun= ... [c] noun= ... format. your sections were the P.O.S, not the ABC's. but i fixed that with A_loopfield.
thanks for the help! _________________ rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
Even monkeys fall from trees. - Japanese proverb |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7299 Location: Australia
|
Posted: Wed Sep 22, 2010 1:08 am Post subject: |
|
|
tidbit, the following seems to be slightly faster than your large if..else ladder:
| Code: | c78=Noun
c80=Plural
c104=NounPhrase
c86=particVerb
c116=transVerb
c105=intVerb
c65=Adjective
c118=Adverb
c67=Conjunction
c80=Preposition
c33=Interjection
c114=Pronoun
c68=DefArticle
c73=IndefArticle
c111=Nominative
...
word2 := Asc(word2)
if (c:=c%word2%) != ""
ini_%letter%_%c% .= word1 ","
| However, using StringCaseSense On (once) and if word2 = char in place of if (word2=="char") comes very close.
Also, you've used "P" for "Plural" and also "Preposition"... |
|
| Back to top |
|
 |
tidbit
Joined: 09 Mar 2008 Posts: 1808 Location: Minnesota, USA
|
Posted: Wed Sep 22, 2010 1:54 am Post subject: |
|
|
Ha, crap. I changed the case of everything to Title Case before the parse
thanks for the catch!
grr. have to redo everything I did to the database and I'm getting more complications then i ever had...
edit: fixed  _________________ rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
Even monkeys fall from trees. - Japanese proverb |
|
| Back to top |
|
 |
DeWild1
Joined: 30 Apr 2006 Posts: 358 Location: Shigle Springs
|
Posted: Fri Oct 15, 2010 11:02 pm Post subject: |
|
|
Very cool. Thank you for your hard work.
I have read much and you have helped me understand functions better.
Q: I need to go through
| Code: | [bla]
var1=a:b:c:d:e:f: |
and remove "c"
How would I do that?
also,
| Code: | [1]
var1=a:b:c:d:e:f:
[2]
var1=a:b:c:d:e:f:
[3]
var1=a:b:c:d:e:f:
[4]
var1=a:b:c:d:e:f:
[5]
var1=a:b:c:d:e:f:
[6]
var1=a:b:c:d:e:f: |
I need to delete 4 then put them back in order.
How would I do that?
Thank you very much and I look forward to using this and learning it. _________________ CPULOCK.com
virusSWAT.com
Computer Repair Computer Service.com
911PCFIX.com |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|