public class SimpleNGramModel extends java.lang.Object implements LanguageModel
Note that all probabilities in the grammar are stored in LogMath log base format. Language Probabilities in the language model file are stored in log 10 base.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
fileName |
protected int |
lineNumber |
protected java.io.BufferedReader |
reader |
PROP_DICTIONARY, PROP_LOCATION, PROP_MAX_DEPTH, PROP_UNIGRAM_WEIGHT
Constructor and Description |
---|
SimpleNGramModel() |
SimpleNGramModel(java.lang.String location,
Dictionary dictionary,
float unigramWeight,
int desiredMaxDepth) |
SimpleNGramModel(java.net.URL urlLocation,
Dictionary dictionary,
float unigramWeight,
int desiredMaxDepth) |
Modifier and Type | Method and Description |
---|---|
void |
allocate()
Create the language model
|
void |
deallocate()
Deallocate resources allocated to this language model
|
void |
dump()
Dumps the language model
|
float |
getBackoff(WordSequence wordSequence)
Returns the backoff probability for the give sequence of words
|
int |
getMaxDepth()
Returns the maximum depth of the language model
|
java.lang.String |
getName() |
java.util.LinkedList<WordSequence> |
getNGrams()
Returns a list of all the word sequences in the language model This
method is used to create Finite State Transducers of the language model.
|
float |
getProbability(WordSequence wordSequence)
Gets the ngram 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 |
onUtteranceEnd()
Called on utterance end to clear cache if needed
|
protected int lineNumber
protected java.io.BufferedReader reader
protected java.lang.String fileName
public SimpleNGramModel(java.lang.String location, Dictionary dictionary, float unigramWeight, int desiredMaxDepth) throws java.net.MalformedURLException, java.lang.ClassNotFoundException
java.net.MalformedURLException
java.lang.ClassNotFoundException
public SimpleNGramModel(java.net.URL urlLocation, Dictionary dictionary, float unigramWeight, int desiredMaxDepth)
public SimpleNGramModel()
public void newProperties(PropertySheet ps) throws PropertyException
Configurable
newProperties
in interface Configurable
ps
- a property sheet holding the new dataPropertyException
- if there is a problem with the properties.public void allocate() throws java.io.IOException
LanguageModel
allocate
in interface LanguageModel
java.io.IOException
- if error occurrspublic void deallocate()
LanguageModel
deallocate
in interface LanguageModel
public java.lang.String getName()
public float getProbability(WordSequence wordSequence)
getProbability
in interface LanguageModel
wordSequence
- the word sequencepublic float getSmear(WordSequence wordSequence)
getSmear
in interface LanguageModel
wordSequence
- the word sequencepublic float getBackoff(WordSequence wordSequence)
wordSequence
- the sequence of wordspublic int getMaxDepth()
getMaxDepth
in interface LanguageModel
public java.util.Set<java.lang.String> getVocabulary()
getVocabulary
in interface LanguageModel
public void onUtteranceEnd()
LanguageModel
onUtteranceEnd
in interface LanguageModel
public void dump()
public java.util.LinkedList<WordSequence> getNGrams()