3 ms·
Nailed it! I scraped some idioms from the web, and take the 10 with the lowest score relative to the input word. To score an idiom relative to an input word,
by saamm 10y ago
Nailed it!
I scraped some idioms from the web, and take the 10 with the lowest score relative to the input word.
To score an idiom relative to an input word, I first convert the input word and each word in the idiom to phonemes (using cmudict [0]). I find the minimum Levenshtein distance between the input word's phonemes and the phonemes of a word in the idiom. The score for the idiom is that minimum distance divided by the number of phonemes in the word that had the minimum score.
The idea with dividing it is to give longer words a bit of a boost (though admittedly I didn't test that rigorously).
0: http://www.speech.cs.cmu.edu/cgi-bin/cmudict http://www.speech.cs.cmu.edu/cgi-bin/cmudict