Here's my version. I just whipped this up now and won't develop it any further.
If you're looking for H_NGM_N, enter h.ngm.n in the first box.
The second box is letters not included. E.g. if you picked 'e' and the word was hangman, you'd put 'e' in this box.
The third is letters already included. This is not generated from the first box because some regEx options and symbols are non-literal letters.
Code:
SetBatchLines -1
#NoEnv
GoSub, DownloadWordList ; if there isn't a local wordlist.txt for the program to use, download it
Loop
{
InputBox Pattern,, Regular Expression Pattern,,,,,,,, %Pattern%
InputBox BadLetters,, Letters not included in the word or phrase (comma delimited),,,,,,,, %BadLetters%
InputBox NoSuggest,, Letters already in words (comma delimited),,,,,,,, %NoSuggest%
if ErrorLevel
Break
count := {}, PossibleWords := ""
Loop Read, %WordListFile%
{
if !Contains(A_LoopReadLine, BadLetters) and RegExMatch(A_LoopReadLine,"i)^(" Pattern ")$"){ ; if this word is a possible choice
Loop Parse, A_LoopReadLine ; count up its letters
if is(A_LoopField, "alpha") and !InStr(NoSuggest, A_LoopField) ; but only count the letters
count[A_LoopField] := count[A_LoopField] ? count[A_LoopField] + 1 : 1
PossibleWords .= A_LoopReadLine . "`n"
}
}
MaxCount := 0
for letter, LetterCount in count
if (LetterCount > MaxCount)
MaxCount := LetterCount, MaxLetter := letter
MsgBox 4,, I suggest '%MaxLetter%'. Is it included?
IfMsgBox Yes
NoSuggest .= (NoSuggest = "" ? "" : ",") . MaxLetter
IfMsgBox No
BadLetters .= (BadLetters = "" ? "" : ",") . MaxLetter
}
return
DownloadWordList:
if !FileExist("WordList.txt") {
URLDownloadToFile http://www.autohotkey.net/~berban/WordList.TXT, Wordlist.txt
if (ErrorLevel) {
MsgBox Could not download a word list. Please choose one.
GoSub, SelectWordList
}
else
WordListFile := "WordList.txt"
}
else
{
Loop WordList.txt
{
WordListFile := A_LoopFileLongPath
break
}
MsgBox, 4,, Found %WordListFile%. Use it?
IfMsgBox No
GoSub, SelectWordList
}
return
SelectWordList:
FileSelectFile WordListFile, 11, , Select a word list
if (ErrorLevel)
ExitApp
return
Contains(a, b){
if a contains %b%
return true
return false
}
is(a, b) {
if a is %b%
return true
return false
}
It works reasonably fast and well for me.
Quote:
"attache lockup"
Actually, I'd suggest "attache cactus", based on the (a/n) hint and the "could grow" hint.