#!/usr/bin/env python2 # This is -*- Python -*- import sys, string sys.path.append("../engine/build/lib.linux-i686-2.2") import gnoetics gnoetics.dictionary_load("../dict/cmudict.0.6") while 1: print ">>> ", line = sys.stdin.readline() line = line.strip() if not line: sys.exit(0) decomp = gnoetics.dictionary_get_word(line) if decomp is None: print "Unknown word '%s'" % string.strip(line) continue print "- %s -\n" % gnoetics.phoneme_decomp_to_string(decomp) R = gnoetics.rhyme_get_all(decomp, 3) R.sort(lambda x, y: cmp(x[0], y[0])) for word, decomp, type in R: print "%-16s %s" % (word, gnoetics.phoneme_decomp_to_string(decomp)) print "%d rhymes found." % len(R) print