public class SimpleBreadthFirstSearchManager extends TokenSearchManager
recognize
until Result.isFinal() returns true. Once a final result has
been obtained, terminate
should be called.
All scores and probabilities are maintained in the log math log domain.
For information about breadth first search please refer to "Spoken Language Processing", X. Huang, PTR
Modifier and Type | Field and Description |
---|---|
protected ActiveList |
activeList |
protected ActiveListFactory |
activeListFactory |
protected java.util.Map<SearchState,Token> |
bestTokenMap |
protected long |
currentCollectTime |
protected int |
currentFrameNumber |
protected Timer |
growTimer |
protected Linguist |
linguist |
protected LogMath |
logMath |
static java.lang.String |
PROP_ACTIVE_LIST_FACTORY
The property that defines the name of the active list factory to be used by this search manager.
|
static java.lang.String |
PROP_GROW_SKIP_INTERVAL
The property that controls the number of frames processed for every time the decode growth step is skipped.
|
static java.lang.String |
PROP_LINGUIST
The property that defines the name of the linguist to be used by this search manager.
|
static java.lang.String |
PROP_PRUNER
The property that defines the name of the linguist to be used by this search manager.
|
static java.lang.String |
PROP_RELATIVE_WORD_BEAM_WIDTH
The property that sets the minimum score relative to the maximum score in the word list for pruning.
|
static java.lang.String |
PROP_SCORER
The property that defines the name of the scorer to be used by this search manager.
|
static java.lang.String |
PROP_SHOW_TOKEN_COUNT
The property that when set to
true will cause the recognizer to count up all the tokens in the
active list after every frame. |
static java.lang.String |
PROP_WANT_ENTRY_PRUNING
The property that controls whether or not relative beam pruning will be performed on the entry into a
state.
|
protected java.util.List<Token> |
resultList |
protected boolean |
showTokenCount |
protected boolean |
streamEnd |
buildWordLattice, keepAllTokens, PROP_BUILD_WORD_LATTICE, PROP_KEEP_ALL_TOKENS
Constructor and Description |
---|
SimpleBreadthFirstSearchManager() |
SimpleBreadthFirstSearchManager(Linguist linguist,
Pruner pruner,
AcousticScorer scorer,
ActiveListFactory activeListFactory,
boolean showTokenCount,
double relativeWordBeamWidth,
int growSkipInterval,
boolean wantEntryPruning)
Creates a manager for simple search
|
Modifier and Type | Method and Description |
---|---|
void |
allocate()
Allocates the resources necessary for this search.
|
protected void |
collectSuccessorTokens(Token token)
Collects the next set of emitting tokens from a token and accumulates them in the active or result lists
|
void |
deallocate()
Deallocates resources necessary for this search.
|
ActiveList |
getActiveList() |
protected Token |
getBestToken(SearchState state)
Gets the best token for this state
|
protected java.util.Map<SearchState,Token> |
getBestTokenMap()
Returns the best token map.
|
int |
getCurrentFrameNumber()
Returns the current frame number.
|
Timer |
getGrowTimer()
Returns the Timer for growing.
|
java.util.List<Token> |
getResultList()
Returns the result list.
|
StatisticsVariable |
getTokensCreated()
Returns the tokensCreated StatisticsVariable.
|
protected void |
growBranches()
Goes through the active list of tokens and expands each token, finding the set of successor tokens until all the
successor tokens are emitting tokens.
|
protected void |
localStart()
Gets the initial grammar node from the linguist and creates a GrammarNodeToken
|
protected void |
localStop()
Local cleanup for this search manager
|
void |
newProperties(PropertySheet ps)
This method is called when this configurable component needs to be reconfigured.
|
protected void |
pruneBranches()
Removes unpromising branches from the active list
|
protected boolean |
recognize()
Performs recognition for one frame.
|
Result |
recognize(int nFrames)
Performs the recognition for the given number of frames.
|
protected boolean |
scoreTokens()
Calculate the acoustic scores for the active list.
|
protected Token |
setBestToken(Token token,
SearchState state)
Sets the best token for a given state
|
protected void |
setBestTokenMap(java.util.Map<SearchState,Token> bestTokenMap)
Sets the best token Map.
|
protected void |
showTokenCount()
Counts all the tokens in the active list (and displays them).
|
void |
startRecognition()
Called at the start of recognition.
|
void |
stopRecognition()
Terminates a recognition
|
java.lang.String |
toString() |
protected ActiveList |
undoLastGrowStep()
Because the growBranches() is called although no data is left after the last speech frame, the ordering of the
active-list might depend on the transition probabilities and (penalty-scores) only.
|
getResultListPredecessor
@S4Component(type=Linguist.class) public static final java.lang.String PROP_LINGUIST
@S4Component(type=Pruner.class) public static final java.lang.String PROP_PRUNER
@S4Component(type=AcousticScorer.class) public static final java.lang.String PROP_SCORER
@S4Component(type=ActiveListFactory.class) public static final java.lang.String PROP_ACTIVE_LIST_FACTORY
@S4Boolean(defaultValue=false) public static final java.lang.String PROP_SHOW_TOKEN_COUNT
true
will cause the recognizer to count up all the tokens in the
active list after every frame.@S4Double(defaultValue=0.0) public static final java.lang.String PROP_RELATIVE_WORD_BEAM_WIDTH
@S4Boolean(defaultValue=false) public static final java.lang.String PROP_WANT_ENTRY_PRUNING
@S4Integer(defaultValue=0) public static final java.lang.String PROP_GROW_SKIP_INTERVAL
protected Linguist linguist
protected int currentFrameNumber
protected long currentCollectTime
protected ActiveList activeList
protected java.util.List<Token> resultList
protected LogMath logMath
protected Timer growTimer
protected boolean showTokenCount
protected java.util.Map<SearchState,Token> bestTokenMap
protected ActiveListFactory activeListFactory
protected boolean streamEnd
public SimpleBreadthFirstSearchManager()
public SimpleBreadthFirstSearchManager(Linguist linguist, Pruner pruner, AcousticScorer scorer, ActiveListFactory activeListFactory, boolean showTokenCount, double relativeWordBeamWidth, int growSkipInterval, boolean wantEntryPruning)
linguist
- linguist to configure search spacepruner
- pruner to prune extra pathsscorer
- scorer to estimate token probabilityactiveListFactory
- factory for list of tokensshowTokenCount
- show count of the tokens during decodingrelativeWordBeamWidth
- relative pruning beam for lookaheadgrowSkipInterval
- interval to skip growth stepwantEntryPruning
- entry pruningpublic void newProperties(PropertySheet ps) throws PropertyException
Configurable
newProperties
in interface Configurable
newProperties
in class TokenSearchManager
ps
- a property sheet holding the new dataPropertyException
- if there is a problem with the properties.public void startRecognition()
public Result recognize(int nFrames)
nFrames
- the number of frames to recognizeprotected ActiveList undoLastGrowStep()
public void stopRecognition()
protected boolean recognize()
true
if recognition is completed.protected void localStart()
protected void localStop()
protected void growBranches()
protected boolean scoreTokens()
true
if there are more frames to score, otherwise, falseprotected void pruneBranches()
protected Token getBestToken(SearchState state)
state
- the state of interestprotected Token setBestToken(Token token, SearchState state)
token
- the best tokenstate
- the statepublic ActiveList getActiveList()
protected void collectSuccessorTokens(Token token)
token
- the token to collect successors fromprotected void showTokenCount()
protected java.util.Map<SearchState,Token> getBestTokenMap()
protected void setBestTokenMap(java.util.Map<SearchState,Token> bestTokenMap)
bestTokenMap
- the new best token Mappublic java.util.List<Token> getResultList()
public int getCurrentFrameNumber()
public Timer getGrowTimer()
public StatisticsVariable getTokensCreated()
public void allocate()
SearchManager
public void deallocate()
SearchManager
public java.lang.String toString()
toString
in class java.lang.Object