Trie Data Structure

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: Trie Data Structure

16 Aug 2017, 16:32

I was wrong about the issue, the problem is when generating the string used to populate the ListBox, turns out that supplying a variadic function with somewhere between 10000 and 141942 strings will crash AHK.
rommmcek wrote:I think the only way to tackle extra large wordlists (1M+) in Ahk is MCode.
It didn't seem to be the problem although I am sure there is a limit to what AHK can handle, but you may be right about using some compiled code, I will have to look into where this script would benefit from it.
Please excuse my spelling I am dyslexic.
User avatar
rommmcek
Posts: 1475
Joined: 15 Aug 2014, 15:18

Re: Trie Data Structure

17 Aug 2017, 13:28

Just tested suggestions with 1.7M words. Works perfect (absolutely no lag) if using:

Code: Select all

	if StrLen(Address) = 1
		return
Otherwise crash!
Maybe is there some kind of a bug, searching with only one letter.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: Trie Data Structure

17 Aug 2017, 13:54

rommmcek wrote:Just tested suggestions with 1.7M words. Works perfect (absolutely no lag) if using:

Code: Select all

	if StrLen(Address) = 1
		return
Otherwise crash!
Maybe is there some kind of a bug, searching with only one letter.
I had not uploaded the fix. You can try again if you want.
Please excuse my spelling I am dyslexic.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: Trie Data Structure

17 Aug 2017, 13:59

I have some code that saves memory, and allow for limiting the number of results, but I feel it is cluttered and hard to follow, should I upload it ?
Please excuse my spelling I am dyslexic.
User avatar
rommmcek
Posts: 1475
Joined: 15 Aug 2014, 15:18

Re: Trie Data Structure

17 Aug 2017, 14:43

Crash again, but this time it was possible to terminate process immediately, so no pain,
P.s.: Post the memory code under the Spoiler.
User avatar
rommmcek
Posts: 1475
Joined: 15 Aug 2014, 15:18

Re: Trie Data Structure

17 Aug 2017, 15:05

Sorry, I used old Suggestions, the new one does not crash! But the lag is considerable (2-3 sec).
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: Trie Data Structure

17 Aug 2017, 18:09

rommmcek wrote:Just tested suggestions with 1.7M words. Works perfect (absolutely no lag) if using:

Code: Select all

	if StrLen(Address) = 1
		return
Otherwise crash!
Maybe is there some kind of a bug, searching with only one letter.
Think of it this way.
If we use the English alphabet and a dictionary of 1.7M evenly distributed words, then we would get the following number of words for keys with length 1 to 4.
1 char: (1 / 26)^1 * 1.7M = 65,385 words
2 char: (1 / 26)^2 * 1.7M = 2,515 words
3 char: (1 / 26)^3 * 1.7M = 97 words
4 char: (1 / 26)^4 * 1.7M = 4 words
Please excuse my spelling I am dyslexic.
User avatar
rommmcek
Posts: 1475
Joined: 15 Aug 2014, 15:18

Re: Trie Data Structure

17 Aug 2017, 20:46

I didn't noticed you display all matches! So you did it! Hat off!
Now I limited the search, but the lag (for one letter) is still to big!

Consider this: Once upon the time I had a very slow machine, so I've split the file to 25 (actually there were more) smaller units and I had quick access to any word!

Is there a way to load big file into more then one Trie?
Besides, is it possible to store the Trie structure on disk, if that would be of any benefit for loading?
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: Trie Data Structure

18 Aug 2017, 01:13

Not displaying all matches is a new feature. Right now it is limited to 500 words, but it have been unlimited to this point.
Please excuse my spelling I am dyslexic.
User avatar
rommmcek
Posts: 1475
Joined: 15 Aug 2014, 15:18

Re: Trie Data Structure

18 Aug 2017, 02:05

Absolutely perfect, the best ever! I am speechless!
User avatar
rommmcek
Posts: 1475
Joined: 15 Aug 2014, 15:18

Re: Trie Data Structure

18 Aug 2017, 03:08

That "perfect" was for one letter entry search speed!

How do you handle capitals? In the suggestions there aren't any captals/majuscules even if present in the list! If there are two identical words except for the capital, only one is shown (with minuscules).

Big thanks for your effort!
User avatar
rommmcek
Posts: 1475
Joined: 15 Aug 2014, 15:18

Re: Trie Data Structure

18 Aug 2017, 05:34

Not exactly as I described (results are dependent on what was the search entry - minuscular/majuscular), but there is inconsistency for sure!
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: Trie Data Structure

21 Aug 2017, 21:09

Thought I would write a progress report. Deletions are done for the uploaded version. I am working on "compressing" the trie, this is working however deletion do not keep the "compression" yet.

Memory usage for the same dictionary with 2,235,194 words:

The Original Script
Image

The Current Script
Image

The Compressed Script
Image
Please excuse my spelling I am dyslexic.
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: Trie Data Structure

22 Aug 2017, 03:16

I like it, thanks.
Just a question: How to 'hide' the windows after the #s ???
User avatar
rommmcek
Posts: 1475
Joined: 15 Aug 2014, 15:18

Re: Trie Data Structure

22 Aug 2017, 05:13

You can do that adding #s::Gui, Hide above Enter:: hotkey/routine.
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: Trie Data Structure

24 Aug 2017, 03:30

Thanks for the reply

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 133 guests