Rhyming Dictionary

April 24, 2012

AA odd     AA D
AE at      AE T
AH hut     HH AH T
AO ought   AO T
AW cow     K AW
AY hide    HH AY D
B  be      B IY
CH cheese  CH IY Z
D  dee     D IY
DH thee    DH IY
EH Ed      EH D
ER hurt    HH ER T
EY ate     EY T
F  fee     F IY
G  green   G R IY N
HH he      HH IY
IH it      IH T
IY eat     IY T
JH gee     JH IY
K  key     K IY
L  lee     L IY
M  me      M IY
N  knee    N IY
NG ping    P IH NG
OW oat     OW T
OY toy     T OY
P  pee     P IY
R  read    R IY D
S  sea     S IY
SH she     SH IY
T  tea     T IY
TH theta   TH EY T AH
UH hood    HH UH D
UW two     T UW
V  vee     V IY
W  we      W IY
Y  yield   Y IY L D
Z  zee     Z IY
ZH seizure S IY ZH ER

Advertisement

Pages: 1 2 3

4 Responses to “Rhyming Dictionary”

  1. sweetopiagirl said

    Reblogged this on InspiredWeightloss!.

  2. Mike said

    Python 2.7 version

    Uses the pronunciation file to build two dictionaries:
    The first one maps a word to its ending phenomes (from the primary stress to the end of the word);
    The second one maps the ending phonemes to a list of words that have that ending.

    do_rhyme() and find_rhymes() then use the dictionaries.

    import gzip
    from collections import defaultdict
    
    db = defaultdict(set)
    rdb = defaultdict(set)
    
    with gzip.open('c06d.gz') as f:
      
      for line in (s.strip() for s in f if s[0].isalpha()):
        
        line = line.split()
        word = line[0]
    
        if word.endswith(')'):
            word = word[:word.index('(')]
    
        ending = []
        for phoneme in reversed(line[1:]):
            ending.append(phoneme)
            if phoneme.endswith('1'):
                break
        ending = ' '.join(reversed(ending))
    
        db[word].add(ending)
        rdb[ending].add(word)
    
    db  = {k:sorted(v) for k,v in db.items()}
    rdb = {k:sorted(v) for k,v in rdb.items()}
    
    def do_rhyme(word1, word2):
      return bool(set(db[word1]).intersection(db[word2]))
    
    def find_rhymes(word):
      return [rdb[sound] for sound in db[word]]
    
    
  3. Gray said

    Ruby style, matching every item after a vowel and building a map of maps of arrays hash[vowel][consonant] = [words with these stuff] (if I understood the rules well :-))

    f = File.new(ARGV[0])
    daMap = Hash.new() do |h, k|
      h[k] = Hash.new() do |hh, kk|
        hh[kk] = Array.new()
      end
    end
    
    while !f.eof()
      line = f.readline()
      trailingStr = /[A-Z]+[0-2] ?([A-Z ]+)*$/.match(line)
      next if trailingStr.nil?()
    
      daWord = /^.*? /.match(line).to_s().chop()
    
      trailingBits = trailingStr.to_s().split(' ')
      vowel = trailingBits.shift()
    
      trailingBits.each() do |bit|
        daMap[vowel][bit] << daWord
      end
    end
    
    daMap.each() do |vowel, trailingGuys|
      trailingGuys.each() do |guy, people|
        if people.size() > 1
          puts "#{people.join(', ')} do rhyme !"
        end
      end
    end
    
  4. robert said

    i like the programming job done at http://www.prime-rhyme.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: