[melbourne-pug] Fun with phononyms

John La Rooy john.larooy at gmail.com
Mon Aug 17 05:09:44 CEST 2009

This is how I would do it.

#!/usr/bin/env python
from string import maketrans

dictionary = "sowpods.txt"
nokia = maketrans("abcdefghijklmnopqrstuvwxyz","22233344455566677778889999")
phononyms = {}

for word in open(dictionary):
    word = word.strip().lower()
    phononyms.setdefault(word.translate(nokia), []).append(word)

for k,v in phononyms.iteritems():
    if len(v) > 1:
        print v

More information about the melbourne-pug mailing list