Ham is a toolkit for manipulating words, pronunciations, and phonemes.
A wrapper around a list of phonemes.
Checks if a phoneme is in this pronunciation.
If the phoneme is an unstressed vowel, that phoneme will be compared against contained vowels without regard to stress. Otherwise, if the phoneme is a stressed vowel sound, the stress will be taken into account.
>>> 'AA' in Pronunciation(['B', 'AA1', 'R', 'N'])
True
>>> 'AW0' in Pronunciation(['B', 'R', 'AW1', 'N'])
False
list of weak references to the object (if defined)
Return the first index of value, starting at the start index given.
If an unstressed vowel is given, will return the first index with that vowel sound regardless of stress. Otherwise index will only find a vowel sound with identical stress.
>>> Pronunciation(['B', 'AA1', 'R', 'N']).index('AA')
1
A SoundPairing is for mapping a word with a pronunciation. It is used as an intermediate step for breaking a word into its phonograms.
list of weak references to the object (if defined)
Encapsulates a word.
list of weak references to the object (if defined)
Return and remove a letter or sequence of letters.
>>> hello = Word('hello')
>>> hello.pop('el')
'el'
>>> str(hello)
'h..lo'
If seq does not exist, raise a ValueError.
Returns a list of Pronunciations for the word.
Looks the word up in the CMU pronouncing dictionary (http://www.speech.cs.cmu.edu/cgi-bin/cmudict)
If the word does not exist in the pronouncing dictionary, return an empty list.
>>> Word('hungry').pronunciations()
[<Pronunciation "HH AH1 NG G R IY0">]
>>> Word('chewbacca').pronunciations()
[]