Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Autocomplete 1.2


  • Please log in to reply
207 replies to this topic
berban_
  • Members
  • 202 posts
  • Last active: Aug 05 2014 11:52 PM
  • Joined: 16 Mar 2011
Holy wordlist batman!! :O :O :O

Disregarding the fact that 1.4GB is a HUGE amount of memory (2.4 kilobytes per word!?!?) that is also a HUGE word list! My list of 109,583 english words is the biggest I've been able to find by quite a good margin. What words are in your list? Where did you find it?

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010

Holy wordlist batman!! :O :O :O

Disregarding the fact that 1.4GB is a HUGE amount of memory (2.4 kilobytes per word!?!?) that is also a HUGE word list! My list of 109,583 english words is the biggest I've been able to find by quite a good margin. What words are in your list? Where did you find it?


Well, technically it is 2.4 KB per word, but tries are designed to take advantage of repetition. The memory usage comes mainly from my use of builtin objects, I'm guessing - they're not particularly small in terms of memory footprint. In the end, I think tries are probably not worth the effort and extra resources needed, as the prefix table is more than fast enough for my needs.

The wordlist was custom compiled from SCOWL and 12dicts dictionaries, and sorted by relevance and then the first character of each word. This allows fast completion while ensuring more relevant words show up closer to the top of the autocompletion list. Note that I have removed all words shorter than five characters, in order to cut down on size, as I found that normally, typing four letter words will be faster than selecting the correct autocomplete option.

  • Guests
  • Last active:
  • Joined: --
I have an idea, if you can like put a phrase in the wordlist.txt instead of word, example "sincerely yours"

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
Yep, you can put phrases in the wordlist just as easily as words. Just make sure they are inserted at the correct place in the wordlist - if it begins with an "S", put it in the section beginning with "S". Only the first letter matters for placement - it's otherwise unsorted.

miami
  • Guests
  • Last active:
  • Joined: --
this is still me, so is it possible to edit script a bit so I don't need to arrange per alpabet 'cause I have tons of new words to add and it's tedious to insert per alphabet

miami
  • Guests
  • Last active:
  • Joined: --
I mean yes I can sort it through excel, that way it is arranged perfectly. What I'm after is this new set of words/phrases gets priority and not necessarily follow the alphabetical order of a particular letter.

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
Hi miami:

Thanks for the suggestion. The reason the script is so fast with hundreds of thousands of words is due to a prefix table, which requires alphabetical sorting. Unfortunately, with wordlists of this size, it is not so simple. For example, it took me over half an hour to sort the (originally unsorted) wordlist and iron out the inconsistencies in the result.

If you want, though, here is a script that will sort by the first character of the wordlist:

FileRead, WordsToAdd, %A_ScriptDir%\WordsToAdd.txt ;a file with the words to add to the wordlist, one word per line
FileRead, WordList, %A_ScriptDir%\WordList.txt ;the wordlist download in my first post

StringReplace, WordsToAdd, WordsToAdd, `r,, All ;remove carriage returns
While, InStr(WordsToAdd,"`n`n") ;remove blank lines
 StringReplace, WordsToAdd, WordsToAdd, `n`n, `n, All
If (SubStr(WordsToAdd,1,1) = "`n")
 WordsToAdd := SubStr(WordsToAdd,2)
If (SubStr(WordsToAdd,0) = "`n")
 WordsToAdd := SubStr(WordsToAdd,1,-1)
AverageLength := StrLen(WordList) // 15 ;average upper bound on wordlist prefix run length
Result := Object("A","","B","","C","","D","","E","","F","","G","","H","","I","","J","K","","L","","M","","N","","O","","P","","Q","","R","","S","","T","","U","","V","","W","","X","","Y","","Z")
For Key In Result ;set the capacity of each key
 ObjSetCapacity(Result,Key,AverageLength)
Loop, Parse, WordsToAdd, `n
 Result[SubStr(WordsToAdd,1,1)] .= A_LoopField . "`n"
Loop, Parse, Wordlist, `n
 Result[SubStr(WordsToAdd,1,1)] .= A_LoopField . "`n"
For Key, Value In Result
 FinalWordList .= Value
FinalWordlist := SubStr(FinalWordlist,1,-1)

FileDelete, %A_ScriptDir%\FinalWordList.txt
FileAppend, %FinalWordlist%, %A_ScriptDir%\FinalWordList.txt

Untested. May take a while to run, and needs about 3 times the amount of memory the wordlist takes up. This script will put the words to add above the priority of the words already present in the wordlist.

dennisk
  • Members
  • 81 posts
  • Last active: Apr 12 2013 08:45 PM
  • Joined: 19 Jun 2011
Would it be possible to change the script so the suggestion box only appears after the first three letters of a word have been typed? TypingAid v2.16b has this feature, but I prefer this script because it is more lightweight.

iBob35555VR
  • Members
  • 89 posts
  • Last active: Dec 24 2012 03:32 PM
  • Joined: 02 Dec 2011
don't Open wordlist.txt with notepad!!!
... All posts where I said the word "smart", maybe, I meant "small" as I had them confused. "Smart script","Smart change" etc are examples.

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010

Would it be possible to change the script so the suggestion box only appears after the first three letters of a word have been typed? TypingAid v2.16b has this feature, but I prefer this script because it is more lightweight.


Done! This setting is tweakable through the ShowLength variable at the top of the script.

adrianromega
  • Guests
  • Last active:
  • Joined: --
Hello guys..

I can;t get this script to work...

I execute it, but when I am trying to test it, no autocomplete appears....

Can somebody help me with this ?

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
Did you download the wordlist and place it in the same directory as the script?

Edit: It should be named Wordlist.txt, by the way.

adrianromega
  • Guests
  • Last active:
  • Joined: --
Thank you for your reply.

Yes, I have that file in the same directory.

this is the code that I am using for Autocomplete, after executing the script I get the total no of lines readed from the wordlist.txt and that is it... from there I cannot figure out what to do.

#NoEnv

WordListFile = %A_ScriptDir%\Wordlist.txt
MaxResults = 30
OffsetX = 0
OffsetY = 20

CoordMode, Caret
FileRead, WordList, %WordListFile%
IfInString, WordList, `r
 StringReplace, WordList, WordList, `r,, All
StringReplace, WordList, WordList, `n, `n, UseErrorLevel
MsgBox % ErrorLevel + 1
ParseList := SubStr(ParseList,1,-1), WordList .= "`n"
Gui, Add, ListBox, x0 y0 w150 h160 vMatched gCompleteWord AltSubmit
Gui, -Caption +ToolWindow +AlwaysOnTop +LastFound
hWnd := WinExist()
Gui, Show, w150 h160 Hide, AutoComplete
SetHotkeys()
Return

GuiClose:
ExitApp

SetHotkeys()
{
 NormKeyList = abcdefghijklmnopqrstuvwxyz1234567890
 ResetKeyList = Esc,Space,Home,PGUP,PGDN,End,Left,Right,RButton,MButton,Enter,`,,.,/,[,],`;,\,-,=,``
 Loop, Parse, NormKeyList
 {
  Hotkey, ~%A_LoopField%, KeyPressed, UseErrorLevel
  Hotkey, ~+%A_LoopField%, ShiftedKey, UseErrorLevel
 }
 Hotkey, ~', KeyPressed, UseErrorLevel
 Loop, Parse, ResetKeyList, CSV
  Hotkey, ~*%A_LoopField%, ResetWord, UseErrorLevel
 Hotkey, ~*", ResetWord, UseErrorLevel
}

KeyPressed:
CurrentWord .= SubStr(A_ThisHotkey,2)
Gosub, Suggest
Return

ShiftedKey:
CurrentWord .= SubStr(A_ThisHotkey,3)
Gosub, Suggest
Return

ResetWord:
CurrentWord = 
Gui, Hide
Return

Suggest:
If CurrentWord = 
{
 Gui, Hide
 Return
}
MatchList := "", Temp3 := StrLen(CurrentWord), Temp2 := 1
While, ((Temp1 := InStr(WordList,"," . CurrentWord,False,Temp2)) && A_Index <= MaxResults)
 Temp1 ++, Temp2 := InStr(WordList,"`n",False,Temp1), MatchList .= "|" . SubStr(WordList,Temp1,Temp2 - Temp1)
If MatchList = 
{
 Gui, Hide
 Return
}
GuiControl,, Matched, %MatchList%
GuiControl, Choose, Matched, 1
Gui, Show, % "x" . (A_CaretX + OffsetX) . " y" . (A_CaretY + OffsetY) . " NoActivate"
Return

CompleteWord:
If A_GuiEvent Not In ,DoubleClick
 Return
GuiControlGet, Temp1,, Matched
MatchList .= "|"
StringGetPos, Temp1, MatchList, |, L%Temp1%
Temp1 += 2 + StrLen(CurrentWord), Temp1 := SubStr(MatchList,Temp1,InStr(MatchList,"|",False,Temp1) - Temp1)
Gosub, ResetWord
SendRaw, %Temp1%
Return

~BackSpace::
StringTrimRight, CurrentWord, CurrentWord, 1
Gosub, Suggest
Return

#IfWinExist AutoComplete ahk_class AutoHotkeyGUI

~LButton::
MouseGetPos,,, Temp1
Temp2 := WinExist("GUI Keyboard")
If Temp1 Not In %hWnd%,%Temp2%
 Gosub, ResetWord
Return

Enter::
Tab::
Gosub, CompleteWord
Return

Up::
GuiControlGet, Temp1,, Matched
GuiControl, Choose, Matched, % Temp1 - 1
Return

Down::
GuiControlGet, Temp1,, Matched
GuiControl, Choose, Matched, % Temp1 + 1
Return

#IfWinActive


Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
It seems as though you are using a very outdated version of the script. Please redownload to see the latest changes.

In the latest version, the dialog only appears after typing three characters, by default.

adrianromega
  • Guests
  • Last active:
  • Joined: --
First, I have downloaded the script that was on the first page of this topic...
That one, when I was loading it, I was receiving errors...
so I have tried another version of the script, the one from the first page, but at the bottom of the script .. for this I do not receive errors, but it;s not working.

Can you please post again the final version of the script ?

Thank you and I really appreciate this.