
Show HN: Finding puns computationally - saamm
http://puns.samueltaylor.org/
======
JoelSanchez
I think I've found a bug: sometimes it does not return puns, but the correct
idioms instead. For example, "words":

a man of few words

a picture paints a thousand words

a woman of few words

actions speak louder than words

mark my words

picture paints a thousand words

put words in somebody’s mouth

Actions speak louder than words

------
mmierz
I love this! But if you choose words that commonly appear in idioms, you just
get the original idiom back. Example:

cat

>cat got your tongue

>cat nap

>curiosity killed the cat

>fight like cat and dog

>grin like a cheshire cat

>let the cat out of the bag

>no room to swing a cat

>not enough room to swing a cat

>not have a cat in hell’s chance

>play cat and mouse

------
ajamesm
> a man's home is his asshole

> don't put all your eggs in one asshole

It checks out.

------
timvdalen
Very cool! How did you build this?

~~~
kenrick95
I found his source code on GitHub. [0]

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](https://github.com/ssaamm/pun-
generator)

1: [https://github.com/ssaamm/pun-
generator/blob/master/src/app....](https://github.com/ssaamm/pun-
generator/blob/master/src/app.py#L105)

~~~
saamm
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)

------
s3arch
>curl your lisp

>program makes perfect

>No puns found :(

------
bbcbasic
girls just Java have fun

better the Java you know

Ha ha! :-)

------
thasaleni
to DRINK home the bacon.

