From this[1], seems like he's taking the top-10 closest (in terms of Lehvenstein distance) phoneme of input and idioms of English language.
0: https://github.com/ssaamm/pun-generator
1: https://github.com/ssaamm/pun-generator/blob/master/src/app....
From this[1], seems like he's taking the top-10 closest (in terms of Lehvenstein distance) phoneme of input and idioms of English language.
0: https://github.com/ssaamm/pun-generator
1: https://github.com/ssaamm/pun-generator/blob/master/src/app....
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).