Alternatives to RegExMatch?

Get help with using AutoHotkey and its commands and hotkeys
littlegandhi1199
Posts: 85
Joined: 29 Aug 2016, 23:58

Alternatives to RegExMatch?

07 Jul 2017, 23:27

Alright.
I've finished my anagram solver and it solves all permutations of 4 letter words up to 15 letter words for an infinitely long word used as your input.
I cracked the code to do it all perfectly and without error and is detailed herehttps://autohotkey.com/boards/viewtopic ... 19&t=34285 along with the script!
Last edited by littlegandhi1199 on 10 Jul 2017, 15:57, edited 1 time in total.
Script Backups on every Execution :mrgreen:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=75767&p=328155#p328155

Scrabble Solver 4-15 letter word outputs ( :crazy: # of inputs)
https://www.autohotkey.com/boards/viewtopic.php?f=19&t=34285
User avatar
YoucefHam
Posts: 344
Joined: 24 Aug 2015, 12:56
Facebook: https://fb.me/YoucefHamDz
Google: [email protected]
GitHub: YoucefHam
Location: Algeria
Contact:

Re: Alternatives to RegExMatch?

08 Jul 2017, 00:28

why you are testing !!!
:wave: There is always more than one way to solve a problem. ;)
littlegandhi1199
Posts: 85
Joined: 29 Aug 2016, 23:58

Re: Alternatives to RegExMatch?

08 Jul 2017, 00:54

YoucefHam wrote:why you are testing !!!
hello again, I made a program that generates permutations of a word (anagram maker) and it compares it against a 5mb dictionary file for any real words.
Does it for 4 letter words, 5 letter words, and up to 11 letter words which when you look at the total permutations it has to do for an 11 letter anagram...
that's 39 million possibilites my friend

even 1ms slower per comparison and my program will take 10 hours longer to complete
Script Backups on every Execution :mrgreen:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=75767&p=328155#p328155

Scrabble Solver 4-15 letter word outputs ( :crazy: # of inputs)
https://www.autohotkey.com/boards/viewtopic.php?f=19&t=34285
Helgef
Posts: 4307
Joined: 17 Jul 2016, 01:02
Contact:

Re: Alternatives to RegExMatch?

08 Jul 2017, 03:27

I suggest you (sort the dictionary and) do a binary search.
littlegandhi1199
Posts: 85
Joined: 29 Aug 2016, 23:58

Re: Alternatives to RegExMatch?

08 Jul 2017, 04:00

Great idea!
Now, how would you search a file differently using binary though?
Script Backups on every Execution :mrgreen:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=75767&p=328155#p328155

Scrabble Solver 4-15 letter word outputs ( :crazy: # of inputs)
https://www.autohotkey.com/boards/viewtopic.php?f=19&t=34285
Helgef
Posts: 4307
Joined: 17 Jul 2016, 01:02
Contact:

Re: Alternatives to RegExMatch?

08 Jul 2017, 04:13

It is very easy to implement a binary search, google it. If you are lazy (it's ok), you can use do something like this, I assume guess ahk uses binary search for key look ups,

Code: Select all

setbatchlines,-1
listlines,off
#noenv
dictionary=	; Use fileread 
(
Bruce
Arnold
Dolph
Chuck
)
Sort, dictionary										; Sort the dictionary if it is not already sorted (not really needed)
strreplace(dictionary, "`n","`n",n)						; Count the lines  (not really needed)
dict:=[]
dict.setcapacity(n)										; Allocate space for n keys. Might improve performance if the dictionary is very big.   (not really needed)
Loop, Parse, dictionary, `n
	dict[A_LoopField]:=A_Index							; Use each word in the dictionary as a key in the dict array
msgbox, % dict.haskey("bruce") ? "Yes on row: " dict["bruce"] : "No" ; this is not case sensitive but I assume it is ok in your case.
dictionary:=""
for k in dict
	str.= k "`n" 
msgbox, % str
So you look up by doing dict.Haskey(...), answer is true or false.
littlegandhi1199
Posts: 85
Joined: 29 Aug 2016, 23:58

Re: Alternatives to RegExMatch?

08 Jul 2017, 05:53

Helgef wrote:It is very easy to implement a binary search, google it. If you are lazy (it's ok), you can use do something like this, I assume guess ahk uses binary search for key look ups,

Code: Select all

setbatchlines,-1
listlines,off
#noenv
dictionary=	; Use fileread 
(
Bruce
Arnold
Dolph
Chuck
)
Sort, dictionary										; Sort the dictionary if it is not already sorted (not really needed)
strreplace(dictionary, "`n","`n",n)						; Count the lines  (not really needed)
dict:=[]
dict.setcapacity(n)										; Allocate space for n keys. Might improve performance if the dictionary is very big.   (not really needed)
Loop, Parse, dictionary, `n
	dict[A_LoopField]:=A_Index							; Use each word in the dictionary as a key in the dict array
msgbox, % dict.haskey("bruce") ? "Yes on row: " dict["bruce"] : "No" ; this is not case sensitive but I assume it is ok in your case.
dictionary:=""
for k in dict
	str.= k "`n" 
msgbox, % str
So you look up by doing dict.Haskey(...), answer is true or false.

Brilliant idea, and your example works but once I put the same thing in txt.txt it fails
brucee
Arnold
Dolph
Chuck



bruce = brucee
FileRead, dictionary, txt.txt
dict =
dict:=[]
Loop, Parse, dictionary, `n
dict[A_LoopField]:=A_Index
if (dict.haskey(bruce) > 0)
msgbox, found "%bruce%" in`n"%dictionary%"
else
msgbox, "%bruce%" is missing from`n"%dictionary%"

dictionary=
(
brucee
Arnold
Dolph
Chuck
)
dict =
dict:=[]
Loop, Parse, dictionary, `n
dict[A_LoopField]:=A_Index
if (dict.haskey(bruce) > 0)
msgbox, found "%bruce%" in`n"%dictionary%"
else
msgbox, "%bruce%" is missing from`n"%dictionary%"
Script Backups on every Execution :mrgreen:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=75767&p=328155#p328155

Scrabble Solver 4-15 letter word outputs ( :crazy: # of inputs)
https://www.autohotkey.com/boards/viewtopic.php?f=19&t=34285
Helgef
Posts: 4307
Joined: 17 Jul 2016, 01:02
Contact:

Re: Alternatives to RegExMatch?

08 Jul 2017, 05:56

Hello, There might an issue with the line breaks. Try to to replace the Loop, ... line with Loop, Parse, dictionary, `n, `r
littlegandhi1199
Posts: 85
Joined: 29 Aug 2016, 23:58

Re: Alternatives to RegExMatch?

08 Jul 2017, 17:10

My own anagram solver that is buggy is already uploaded somewhere.
Once I fix it I will add to your guys' too
Script Backups on every Execution :mrgreen:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=75767&p=328155#p328155

Scrabble Solver 4-15 letter word outputs ( :crazy: # of inputs)
https://www.autohotkey.com/boards/viewtopic.php?f=19&t=34285

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 185 guests