|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnick.syllable.DictionarySyllabilizer
public class DictionarySyllabilizer
This class loads a specified dictionary file into memory. This class was designed to work with the Carnegie Mellon Pronouncing Dictionary version cmudict.0.6d. The dictionary contains about 130,000 words. This project would not be possible without their work.
The expected file format is as follows:
WORD PRONOUNCIATION_INFO
Where 'WORD' is a single word in the dictionary and 'PRONOUNCIATION_INFO' is a string that contains numerical values indicating lexical stress. Each syllable has a numerical value indicating no stress, primary stress or secondary stress. This class ignores all information besides the number of times these values appear.
For example:
STEWARDESSES S T UW1 ER0 D AH0 S IH0 Z
The word is stewardesses and its pronunciation information contains the digits 1,0,0,0. These values occur four times and therefore the word has four syllables. Case is is ignored by this class.
This class is very basic and provides efficient access and lookups. The basic accessor methods randomWord(), wordInDictionary(), getSyllables() and dictionarySize() run in expected O(1) time.
Constructor Summary | |
---|---|
DictionarySyllabilizer(java.lang.String file_name)
Construct a Dictionary Syllabilizer object |
Method Summary | |
---|---|
java.lang.String[] |
dictionary()
|
int |
dictionarySize()
|
int |
getSyllables(java.lang.String key)
Provide the number of syllables for a given word. |
java.lang.String |
randomWord()
|
boolean |
wordInDictionary(java.lang.String key)
Find out if a given word is in the dictionary. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DictionarySyllabilizer(java.lang.String file_name) throws java.io.IOException
file_name
- The name of the file to load.
java.io.IOException
Method Detail |
---|
public int getSyllables(java.lang.String key)
key
- The word to search.
public java.lang.String randomWord()
public boolean wordInDictionary(java.lang.String key)
key
- The word to check.
public int dictionarySize()
public java.lang.String[] dictionary()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |