edu.cmu.sphinx.linguist.language.classes
Class ClassBasedLanguageModel

java.lang.Object
  extended by edu.cmu.sphinx.linguist.language.classes.ClassBasedLanguageModel
All Implemented Interfaces:
LanguageModel, Configurable

public class ClassBasedLanguageModel
extends java.lang.Object
implements LanguageModel

An LM that computes a probability of a word sequence by converting words to classes and asking the class-based probability from a delegate LM.

Author:
Tanel Alumae

Field Summary
static java.lang.String PROP_CLASS_LANGUAGE_MODEL
          Sphinx property that defines the classLanguageModel component.
static java.lang.String PROP_CLASS_MAP
          Sphinx property that defines the classMap component.
static java.lang.String PROP_LOG_MATH
          Sphinx property that defines the logMath component.
 
Fields inherited from interface edu.cmu.sphinx.linguist.language.ngram.LanguageModel
PROP_DICTIONARY, PROP_FORMAT, PROP_LOCATION, PROP_MAX_DEPTH, PROP_UNIGRAM_WEIGHT
 
Constructor Summary
ClassBasedLanguageModel()
           
ClassBasedLanguageModel(ClassMap classMap, LanguageModel classLM, LogMath logMath)
           
 
Method Summary
 void allocate()
          Create the language model
 void deallocate()
          Deallocate resources allocated to this language model
 int getMaxDepth()
          Returns the maximum depth of the language model
 float getProbability(WordSequence wordSequence)
          Gets the n-gram probability of the word sequence represented by the word list
 float getSmear(WordSequence wordSequence)
          Gets the smear term for the given wordSequence
 java.util.Set<java.lang.String> getVocabulary()
          Returns the set of words in the language model.
 void newProperties(PropertySheet ps)
          This method is called when this configurable component needs to be reconfigured.
 void start()
          Called before a recognition
 void stop()
          Called after a recognition
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_LOG_MATH

@S4Component(type=LogMath.class)
public static final java.lang.String PROP_LOG_MATH
Sphinx property that defines the logMath component.

See Also:
Constant Field Values

PROP_CLASS_LANGUAGE_MODEL

@S4Component(type=LanguageModel.class)
public static final java.lang.String PROP_CLASS_LANGUAGE_MODEL
Sphinx property that defines the classLanguageModel component.

See Also:
Constant Field Values

PROP_CLASS_MAP

@S4Component(type=ClassMap.class)
public static final java.lang.String PROP_CLASS_MAP
Sphinx property that defines the classMap component.

See Also:
Constant Field Values
Constructor Detail

ClassBasedLanguageModel

public ClassBasedLanguageModel(ClassMap classMap,
                               LanguageModel classLM,
                               LogMath logMath)

ClassBasedLanguageModel

public ClassBasedLanguageModel()
Method Detail

newProperties

public void newProperties(PropertySheet ps)
                   throws PropertyException
Description copied from interface: Configurable
This method is called when this configurable component needs to be reconfigured.

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.

allocate

public void allocate()
              throws java.io.IOException
Description copied from interface: LanguageModel
Create the language model

Specified by:
allocate in interface LanguageModel
Throws:
java.io.IOException

deallocate

public void deallocate()
Description copied from interface: LanguageModel
Deallocate resources allocated to this language model

Specified by:
deallocate in interface LanguageModel

start

public void start()
Called before a recognition

Specified by:
start in interface LanguageModel

stop

public void stop()
Called after a recognition

Specified by:
stop in interface LanguageModel

getProbability

public float getProbability(WordSequence wordSequence)
Description copied from interface: LanguageModel
Gets the n-gram probability of the word sequence represented by the word list

Specified by:
getProbability in interface LanguageModel
Parameters:
wordSequence - the wordSequence
Returns:
the probability of the word sequence in LogMath log base

getSmear

public float getSmear(WordSequence wordSequence)
Gets the smear term for the given wordSequence

Specified by:
getSmear in interface LanguageModel
Parameters:
wordSequence - the word sequence
Returns:
the smear term associated with this word sequence

getVocabulary

public java.util.Set<java.lang.String> getVocabulary()
Description copied from interface: LanguageModel
Returns the set of words in the language model. The set is unmodifiable.

Specified by:
getVocabulary in interface LanguageModel
Returns:
the unmodifiable set of words

getMaxDepth

public int getMaxDepth()
Returns the maximum depth of the language model

Specified by:
getMaxDepth in interface LanguageModel
Returns:
the maximum depth of the language mdoel