[melbourne-pug] Fun with phononyms

martin schweitzer schweitzer.ubiquitous at gmail.com
Mon Aug 17 04:14:36 CEST 2009

I hope this is not an abuse of this mailing list - and hopefully it will
encourage the discussion and use of Python :-)

A workmate asked me the other day what name I would give to two words that
come up from the same numbers using predictive text on a mobile phone.  Eg.
if you type 4,6,6,3 it comes up as either HOME or GOOD.  He came up with the
word 'Nokianym' and someone else came up with Phononym.  A quick google
search revealed that phononym is already well known (eg.

Anyway, I wrote a quick program to find all phononyms in a dictionary.  It
was a first attempt and I am sure it can be done more elegantly - but I
thought I would post my program here and people may be interested in posting



# My python v3.0 hack...
def print3(text): print text

# A list of words (that are legal in scrabble)...
dictionary = 'sowpods.txt'

nokia = {'a':2, 'b':2, 'c':2,
       'd':3, 'e':3, 'f':3,
       'g':4, 'h':4, 'i':4,
       'j':5, 'k':5, 'l':5,
       'm':6, 'n':6, 'o':6,
       'p':7, 'q':7, 'r':7, 's':7,
       't':8, 'u':8, 'v':8,
       'w':9, 'x':9, 'y':9, 'z':9

# Yes, the following function could be shortened, but I have
# gone for reading comprehension over list comprehension...
def get_val(word):
    result = 0
    word = word.lower()
    for c in word:
        if nokia.has_key(c):
            result = result * 10 + nokia[c]
    return result

phononyms = {}
for word in open(dictionary):
    word = word.rstrip('\n\r')

    val = get_val(word)
    if (not phononyms.has_key(val)):
        phononyms[val] = []

    for val in phononyms.keys()
        if len(phononyms[val]) > 1]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/melbourne-pug/attachments/20090817/e374ae3b/attachment.htm>

More information about the melbourne-pug mailing list