public class WordPruningBreadthFirstSearchManager extends TokenSearchManager
recognize
until Result.isFinal() returns true. Once a final
result has been obtained, stopRecognition
should be called.
All scores and probabilities are maintained in the log math log domain.
Modifier and Type | Field and Description |
---|---|
protected float |
acousticLookaheadFrames |
protected ActiveList |
activeList |
protected java.util.Map<SearchState,Token> |
bestTokenMap |
protected boolean |
checkStateOrder |
protected long |
currentCollectTime |
protected int |
currentFrameNumber |
protected StatisticsVariable |
curTokensScored |
protected Timer |
growTimer |
protected Linguist |
linguist |
protected java.util.logging.Logger |
logger |
protected LogMath |
logMath |
protected AlternateHypothesisManager |
loserManager |
static java.lang.String |
PROP_ACOUSTIC_LOOKAHEAD_FRAMES
The property that controls the amount of simple acoustic lookahead
performed.
|
static java.lang.String |
PROP_ACTIVE_LIST_MANAGER
The property that defines the type of active list to use
|
static java.lang.String |
PROP_CHECK_STATE_ORDER
The property for checking if the order of states is valid.
|
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_MAX_LATTICE_EDGES
The property that specifies the maximum lattice edges
|
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_BEAM_WIDTH
The property that specifies the relative beam width
|
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 than, when set to
true will cause the
recognizer to count up all the tokens in the active list after every
frame. |
protected Pruner |
pruner |
protected Timer |
pruneTimer |
protected float |
relativeBeamWidth |
protected java.util.List<Token> |
resultList |
protected AcousticScorer |
scorer |
protected Timer |
scoreTimer |
protected boolean |
showTokenCount |
protected boolean |
streamEnd |
protected StatisticsVariable |
tokensCreated |
protected StatisticsVariable |
totalTokensScored |
buildWordLattice, keepAllTokens, PROP_BUILD_WORD_LATTICE, PROP_KEEP_ALL_TOKENS
Constructor and Description |
---|
WordPruningBreadthFirstSearchManager() |
WordPruningBreadthFirstSearchManager(Linguist linguist,
Pruner pruner,
AcousticScorer scorer,
ActiveListManager activeListManager,
boolean showTokenCount,
double relativeWordBeamWidth,
int growSkipInterval,
boolean checkStateOrder,
boolean buildWordLattice,
int maxLatticeEdges,
float acousticLookaheadFrames,
boolean keepAllTokens)
Creates a pruning manager withs separate lists for tokens
|
Modifier and Type | Method and Description |
---|---|
protected void |
activeListAdd(Token token) |
void |
allocate()
Allocates the resources necessary for this search.
|
protected boolean |
allowExpansion(Token t)
Determine if the given token should be expanded
|
protected void |
checkStateOrder(SearchState fromState,
SearchState toState)
Checks that the given two states are in legitimate order.
|
protected void |
collectSuccessorTokens(Token token)
Collects the next set of emitting tokens from a token and accumulates
them in the active or result lists
|
protected void |
createBestTokenMap()
creates a new best token map with the best size
|
void |
deallocate()
Deallocates resources necessary for this search.
|
ActiveList |
getActiveList()
Returns the ActiveList.
|
protected Token |
getBestToken(SearchState state)
Gets the best token for this state
|
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 |
growEmittingBranches()
Grows the emitting branches.
|
protected boolean |
isVisited(Token t)
Determines whether or not we've visited the state associated with this
token since the previous frame.
|
protected void |
localStart()
Gets the initial grammar node from the linguist and creates a
GrammarNodeToken
|
protected void |
localStop()
Local cleanup for this search manager
|
protected void |
monitorStates(ActiveList activeList)
Keeps track of and reports statistics about the number of active states
|
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() |
Result |
recognize(int nFrames)
Performs the recognition for the given number of frames.
|
protected boolean |
scoreTokens()
Calculate the acoustic scores for the active list.
|
void |
setActiveList(ActiveList activeList)
Sets the ActiveList.
|
protected void |
setBestToken(Token token,
SearchState state)
Sets the best token for a given state
|
void |
setResultList(java.util.List<Token> resultList)
Sets the result list.
|
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
|
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
@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.@S4Integer(defaultValue=0) public static final java.lang.String PROP_GROW_SKIP_INTERVAL
@S4Component(type=ActiveListManager.class) public static final java.lang.String PROP_ACTIVE_LIST_MANAGER
@S4Boolean(defaultValue=false) public static final java.lang.String PROP_CHECK_STATE_ORDER
@S4Integer(defaultValue=100) public static final java.lang.String PROP_MAX_LATTICE_EDGES
@S4Double(defaultValue=0.0) public static final java.lang.String PROP_ACOUSTIC_LOOKAHEAD_FRAMES
@S4Double(defaultValue=0.0) public static final java.lang.String PROP_RELATIVE_BEAM_WIDTH
protected Linguist linguist
protected Pruner pruner
protected AcousticScorer scorer
protected LogMath logMath
protected java.util.logging.Logger logger
protected boolean showTokenCount
protected boolean checkStateOrder
protected float relativeBeamWidth
protected float acousticLookaheadFrames
protected Timer scoreTimer
protected Timer pruneTimer
protected Timer growTimer
protected StatisticsVariable totalTokensScored
protected StatisticsVariable curTokensScored
protected StatisticsVariable tokensCreated
protected int currentFrameNumber
protected long currentCollectTime
protected ActiveList activeList
protected java.util.List<Token> resultList
protected java.util.Map<SearchState,Token> bestTokenMap
protected AlternateHypothesisManager loserManager
protected boolean streamEnd
public WordPruningBreadthFirstSearchManager(Linguist linguist, Pruner pruner, AcousticScorer scorer, ActiveListManager activeListManager, boolean showTokenCount, double relativeWordBeamWidth, int growSkipInterval, boolean checkStateOrder, boolean buildWordLattice, int maxLatticeEdges, float acousticLookaheadFrames, boolean keepAllTokens)
linguist
- a linguist for search spacepruner
- pruner to drop tokensscorer
- scorer to estimate token probabilityactiveListManager
- active list manager to store tokensshowTokenCount
- show count during decodingrelativeWordBeamWidth
- relative beam for lookahead pruninggrowSkipInterval
- skip interval for growncheckStateOrder
- check order of states during growthbuildWordLattice
- build a lattice during decodingmaxLatticeEdges
- max edges to keep in latticeacousticLookaheadFrames
- frames to do lookaheadkeepAllTokens
- keep tokens including emitting tokenspublic WordPruningBreadthFirstSearchManager()
public 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 allocate()
SearchManager
public void deallocate()
SearchManager
public void startRecognition()
public Result recognize(int nFrames)
nFrames
- the number of frames to recognizeprotected boolean recognize()
protected void createBestTokenMap()
public void stopRecognition()
protected void localStart()
protected void localStop()
protected void growBranches()
protected void growEmittingBranches()
protected boolean scoreTokens()
true
if there are more frames to score, otherwise,
falseprotected void monitorStates(ActiveList activeList)
activeList
- the active list of statesprotected void pruneBranches()
protected Token getBestToken(SearchState state)
state
- the state of interestprotected void setBestToken(Token token, SearchState state)
token
- the best tokenstate
- the stateprotected void checkStateOrder(SearchState fromState, SearchState toState)
fromState
- parent statetoState
- child stateprotected void collectSuccessorTokens(Token token)
token
- the token to collect successors from be immediately expanded
are placed. Null if we should always expand all nodes.protected boolean isVisited(Token t)
t
- token to checkprotected void activeListAdd(Token token)
protected boolean allowExpansion(Token t)
t
- the token to testtrue
if the token should be expandedprotected void showTokenCount()
public ActiveList getActiveList()
public void setActiveList(ActiveList activeList)
activeList
- the new ActiveListpublic java.util.List<Token> getResultList()
public void setResultList(java.util.List<Token> resultList)
resultList
- the new result listpublic int getCurrentFrameNumber()
public Timer getGrowTimer()
public StatisticsVariable getTokensCreated()