Hacker News new | comments | show | ask | jobs | submit login
Show HN: Finding puns computationally (samueltaylor.org)
24 points by saamm on Sept 26, 2016 | hide | past | web | favorite | 9 comments



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


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


> a man's home is his asshole

> don't put all your eggs in one asshole

It checks out.


Very cool! How did you build this?


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

1: https://github.com/ssaamm/pun-generator/blob/master/src/app....


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


>curl your lisp

>program makes perfect

>No puns found :(


girls just Java have fun

better the Java you know

Ha ha! :-)


to DRINK home the bacon.




Applications are open for YC Summer 2018

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: