Hello!I have a simple bash script that matches words with bits missing. I use it to help me solve crosswords, as in,
grep '\<'$mysteryword'\>' /usr/share/dict/words
You enter the word you want to find, and use full-stops for the characters you don't know, and by grepping the dictionary, it returns all possible matches. I'd like to add a commandline argument -s or something to match only synonyms of a chosen word or series of words. The excellent package "dict" has the thesaurus add-on "dict-moby-thesaurus". Its output looks something like this:
~> dict hello
1 definition found
From Moby Thesaurus II by Grady Ward, 1.0 [moby-thesaurus]:
19 Moby Thesaurus words for "hello":
accost, address, bob, bow, curtsy, embrace, greeting, hail,
hand-clasp, handshake, how-do-you-do, hug, kiss, nod, salutation,
salute, smile, smile of recognition, wave
The command would be something like
~> crossword .r..t..g -s hello
It would scan for words that fit the dotty word, and then filter for words that only match the ones given by the thesaurus and return only those as possibilities. I suppose it'd be more efficient to have these things work the other way around.
I guess this might be a good time to start learning how to use awk or something, but I don't really know how to proceed. The tutorials I've found look pretty imposing. Has anyone any pointers for me?
Alternatively, I could use the thesaurus source file, which lists the synonyms of each word line-by-line. The line for "A-Bomb" looks a bit like this:
A-bomb,H-bomb,atomic bomb,atomic warhead,clean bomb,cobalt bomb,dirty bomb,fusion bomb,hell bomb,hydrogen bomb...(etc)
I suppose grepping here might work, but that file is pretty massive, and there would be way too many hits for the filter to work with. Hrmm. What do you think?
Grateful for any advice!