public class NetworkLanguageModel extends java.lang.Object implements LanguageModel
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PROP_HOST
The property specifying the host of the language model server.
|
static java.lang.String |
PROP_PORT
The property specifying the port of the language model server.
|
PROP_DICTIONARY, PROP_LOCATION, PROP_MAX_DEPTH, PROP_UNIGRAM_WEIGHT
Constructor and Description |
---|
NetworkLanguageModel() |
NetworkLanguageModel(java.lang.String host,
int port,
java.net.URL location,
int maxDepth)
Creates network language model client
|
Modifier and Type | Method and Description |
---|---|
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 |
onUtteranceEnd()
Called on utterance end to clear cache if needed
|
@S4String(defaultValue="localhost") public static final java.lang.String PROP_HOST
@S4Integer(defaultValue=2525) public static final java.lang.String PROP_PORT
public NetworkLanguageModel(java.lang.String host, int port, java.net.URL location, int maxDepth)
host
- server hostport
- server portlocation
- URL of the file with vocabulary (only needed for 1-stage
model)maxDepth
- depth of the modelpublic NetworkLanguageModel()
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 int getMaxDepth()
LanguageModel
getMaxDepth
in interface LanguageModel
public float getProbability(WordSequence wordSequence)
LanguageModel
getProbability
in interface LanguageModel
wordSequence
- the wordSequencepublic float getSmear(WordSequence wordSequence)
LanguageModel
LexTreeLinguist
. See
LexTreeLinguist.PROP_WANT_UNIGRAM_SMEAR
for details.getSmear
in interface LanguageModel
wordSequence
- the word sequencepublic java.util.Set<java.lang.String> getVocabulary()
LanguageModel
getVocabulary
in interface LanguageModel
public void onUtteranceEnd()
LanguageModel
onUtteranceEnd
in interface LanguageModel