edu.cmu.sphinx.linguist.dictionary
Class FastDictionary

java.lang.Object
  extended byedu.cmu.sphinx.linguist.dictionary.FastDictionary
All Implemented Interfaces:
Configurable, Dictionary

public class FastDictionary
extends java.lang.Object
implements Dictionary

Creates a dictionary by quickly reading in an ASCII-based Sphinx-3 format dictionary. It is called the FastDictionary because the loading is fast. When loaded the dictionary just loads each line of the dictionary into the hash table, assuming that most words are not going to be used. Only when a word is actually used is its pronunciations massaged into an array of pronunciations.

The format of the ASCII dictionary that it explains is the same as the FullDictionary, i.e., the word, followed by spaces or tab, followed by the pronunciation(s). For example, a digits dictionary will look like:

  ONE HH W AH N
  ONE(2) W AH N
  TWO T UW
  THREE TH R IY
  FOUR F AO R
  FIVE F AY V
  SIX S IH K S
  SEVEN S EH V AH N
  EIGHT EY T
  NINE N AY N
  ZERO Z IH R OW
  ZERO(2) Z IY R OW
  OH OW
 

In the above example, the words "one" and "zero" have two pronunciations each.


Field Summary
 
Fields inherited from interface edu.cmu.sphinx.linguist.dictionary.Dictionary
PROP_ADD_SIL_ENDING_PRONUNCIATION, PROP_ADD_SIL_ENDING_PRONUNCIATION_DEFAULT, PROP_ALLOW_MISSING_WORDS, PROP_ALLOW_MISSING_WORDS_DEFAULT, PROP_CREATE_MISSING_WORDS, PROP_CREATE_MISSING_WORDS_DEFAULT, PROP_DICTIONARY, PROP_DICTIONARY_DEFAULT, PROP_FILLER_DICTIONARY, PROP_FILLER_DICTIONARY_DEFAULT, PROP_LOCATION, PROP_LOCATION_DEFAULT, PROP_UNIT_MANAGER, PROP_WORD_REPLACEMENT, PROP_WORD_REPLACEMENT_DEFAULT, SENTENCE_END_SPELLING, SENTENCE_START_SPELLING, SILENCE_SPELLING
 
Constructor Summary
FastDictionary()
           
 
Method Summary
 void allocate()
          Allocates the dictionary
 void deallocate()
          Deallocates the dictionary
 void dump()
          Dumps this FastDictionary to System.out.
 Word[] getFillerWords()
          Gets the set of all filler words in the dictionary
 java.lang.String getName()
          Retrieves the name for this configurable component
 WordClassification[] getPossibleWordClassifications()
          Returns the set of all possible word classifications for this dictionary.
 Word getSentenceEndWord()
          Returns the sentence end word.
 Word getSentenceStartWord()
          Returns the sentence start word.
 Word getSilenceWord()
          Returns the silence word.
 Word getWord(java.lang.String text)
          Returns a Word object based on the spelling and its classification.
 void newProperties(PropertySheet ps)
          This method is called when this configurable component has new data.
 void register(java.lang.String name, Registry registry)
          Register my properties.
 java.lang.String toString()
          Returns a string representation of this FastDictionary in alphabetical order.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FastDictionary

public FastDictionary()
Method Detail

register

public void register(java.lang.String name,
                     Registry registry)
              throws PropertyException
Description copied from interface: Configurable
Register my properties. This method is called once early in the time of the component, shortly after the component is constructed. This component should register any configuration properties that it needs to register. If this configurable extends another configurable, super.register should also be called

Specified by:
register in interface Configurable
Parameters:
name - the name of the component
registry - the registry for this component
Throws:
PropertyException

newProperties

public void newProperties(PropertySheet ps)
                   throws PropertyException
Description copied from interface: Configurable
This method is called when this configurable component has new data. The component should first validate the data. If it is bad the component should return false. If the data is good, the component should record the the data internally and return true.

Specified by:
newProperties in interface Configurable
Parameters:
ps - a property sheet holding the new data
Throws:
PropertyException - if there is a problem with the properties.

getName

public java.lang.String getName()
Description copied from interface: Configurable
Retrieves the name for this configurable component

Specified by:
getName in interface Configurable
Returns:
the name

allocate

public void allocate()
              throws java.io.IOException
Description copied from interface: Dictionary
Allocates the dictionary

Specified by:
allocate in interface Dictionary
Throws:
java.io.IOException - if there is trouble loading the dictionary

deallocate

public void deallocate()
Description copied from interface: Dictionary
Deallocates the dictionary

Specified by:
deallocate in interface Dictionary

getSentenceStartWord

public Word getSentenceStartWord()
Returns the sentence start word.

Specified by:
getSentenceStartWord in interface Dictionary
Returns:
the sentence start word

getSentenceEndWord

public Word getSentenceEndWord()
Returns the sentence end word.

Specified by:
getSentenceEndWord in interface Dictionary
Returns:
the sentence end word

getSilenceWord

public Word getSilenceWord()
Returns the silence word.

Specified by:
getSilenceWord in interface Dictionary
Returns:
the silence word

getWord

public Word getWord(java.lang.String text)
Returns a Word object based on the spelling and its classification. The behavior of this method is also affected by the properties wordReplacement, allowMissingWords, and createMissingWords.

Specified by:
getWord in interface Dictionary
Parameters:
text - the spelling of the word of interest.
Returns:
a Word object
See Also:
Word

getPossibleWordClassifications

public WordClassification[] getPossibleWordClassifications()
Returns the set of all possible word classifications for this dictionary.

Specified by:
getPossibleWordClassifications in interface Dictionary
Returns:
the set of all possible word classifications

toString

public java.lang.String toString()
Returns a string representation of this FastDictionary in alphabetical order.

Returns:
a string representation of this FastDictionary

getFillerWords

public Word[] getFillerWords()
Gets the set of all filler words in the dictionary

Specified by:
getFillerWords in interface Dictionary
Returns:
an array (possibly empty) of all filler words

dump

public void dump()
Dumps this FastDictionary to System.out.

Specified by:
dump in interface Dictionary