|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.cmu.sphinx.result.Lattice
Provides recognition lattice results. Lattices are created from
Results
which can be partial or final.
Lattices describe all theories considered by the Recognizer that have not
been pruned out. Lattices are a directed graph containing
Nodes
and
Edges
.
A Node that correponds to a theory that a word was spoken over a particular
period of time. An Edge that corresponds to the score of one word following
another. The usual result transcript is the sequence of Nodes though the
Lattice with the best scoring path. Lattices are a useful tool for
analyzing "alternate results".
A Lattice can be created from a Result that has a full token tree
(with its corresponding AlternativeHypothesisManager).
Currently, only the
WordPruningBreadthFirstSearchManager
has an AlternativeHypothesisManager. Furthermore, the lattice
construction code currently only works for linguists where the
WordSearchState
returns false on the
isWordStart
method, i.e., where the word states appear
at the end of the word in the linguist. Therefore, lattices should
only be created from Result from the
LexTreeLinguist
and the
WordPruningBreadthFirstSearchManager
.
Lattices can also be created from a collapsed
Token
tree and its
AlternativeHypothesisManager. This is what 'collapsed' means.
Normally, between two word tokens is a series of tokens for other types
of states, such as unit or HMM states. Using 'W' for word tokens,
'U' for unit tokens, 'H' for HMM tokens, a token chain can look like:
W - U - H - H - H - H - U - H - H - H - H - W
Usually, HMM tokens contains acoustic scores, and word tokens contains language scores. If we want to know the total acoustic and language scores between any two words, it is unnecessary to keep around the unit and HMM tokens. Therefore, all their acoustic and language scores are 'collapsed' into one token, so that it will look like:
W - P - W
where 'P' is a token that represents the path between the two words,
and P contains the acoustic and language scores between the two words.
It is this type of collapsed token tree that the Lattice class is
expecting. Normally, the task of collapsing the token tree is done
by the
WordPruningBreadthFirstSearchManager
.
A collapsed token tree can look like:
"cat" - P - </s> / P / <s> - P - "a" - P - "big" \ P \ "dog" - P - </s>
When a Lattice is constructed from a Result, the above collapsed token tree together with the alternate hypothesis of "all" instead of "a", will be converted into a Lattice that looks like the following:
"a" "cat" / \ / \ <s> "big" - </s> \ / \ / "all" "dog"
Initially, a lattice can have redundant nodes, i.e., nodes referring to
the same word and that originate from the same parent node. These
nodes can be collapsed using the LatticeOptimizer
.
Constructor Summary | |
Lattice(Result result)
Create a Lattice from a Result. |
|
Lattice(java.lang.String fileName)
Create a Lattice from a LAT file. |
Method Summary | |
Edge |
addEdge(Node fromNode,
Node toNode,
double acousticScore,
double lmScore)
Add an edge from fromNode to toNode. |
Node |
addNode(java.lang.String word,
int beginTime,
int endTime)
Add a Node that represents the theory that a given word was spoken over a given period of time. |
Node |
addNode(Word word,
int beginTime,
int endTime)
Add a Node that represents the theory that a given word was spoken over a given period of time. |
java.util.List |
allPaths()
Generate a List of all paths through this Lattice. |
void |
computeNodePosteriors(float languageModelWeight)
Compute the utterance-level posterior for every node in the lattice, i.e. the probability that this node occurs on any path through the lattice. |
void |
computeNodePosteriors(float languageModelWeight,
boolean useAcousticScoresOnly)
Compute the utterance-level posterior for every node in the lattice, i.e. the probability that this node occurs on any path through the lattice. |
void |
dump(java.lang.String file)
Dump the Lattice as a .LAT file. |
void |
dumpAISee(java.lang.String fileName,
java.lang.String title)
Dump the Lattice in the form understood by AiSee (a graph visualization tool). |
void |
dumpAllPaths()
Dump all paths through this Lattice. |
java.util.Collection |
getEdges()
Get the set of all Edges. |
Node |
getInitialNode()
Get the initialNode for this Lattice. |
double |
getLogBase()
Edge scores are usually log-likelyhood. |
LogMath |
getLogMath()
|
java.util.Collection |
getNodes()
Get the Collection of all Nodes. |
Node |
getTerminalNode()
Get the terminalNode for this Lattice. |
boolean |
isEquivalent(Lattice other)
Returns true if the given Lattice is equivalent to this Lattice. |
static void |
main(java.lang.String[] args)
Self test for Lattices. |
void |
setInitialNode(Node p_initialNode)
Set the initialNode for this Lattice. |
void |
setLogMath(LogMath logMath)
Sets the LogMath to use. |
void |
setTerminalNode(Node p_terminalNode)
Set the terminalNode for this Lattice. |
java.util.List |
sortNodes()
Topologically sort the nodes in this lattice. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Lattice(Result result)
result
- the result to convert into a latticepublic Lattice(java.lang.String fileName)
fileName
- Method Detail |
public Edge addEdge(Node fromNode, Node toNode, double acousticScore, double lmScore)
fromNode
- toNode
- acousticScore
- lmScore
-
public Node addNode(Word word, int beginTime, int endTime)
word
- beginTime
- endTime
-
public Node addNode(java.lang.String word, int beginTime, int endTime)
word
- beginTime
- endTime
-
public java.util.Collection getNodes()
public java.util.Collection getEdges()
public void dumpAISee(java.lang.String fileName, java.lang.String title)
fileName
- title
- public void dump(java.lang.String file)
file
- public Node getInitialNode()
public void setInitialNode(Node p_initialNode)
p_initialNode
- public Node getTerminalNode()
public void setTerminalNode(Node p_terminalNode)
p_terminalNode
- public double getLogBase()
public LogMath getLogMath()
public void setLogMath(LogMath logMath)
logMath
- the LogMath to usepublic void dumpAllPaths()
public java.util.List allPaths()
public java.util.List sortNodes()
public void computeNodePosteriors(float languageModelWeight)
languageModelWeight
- the language model weight that was used
in generating the scores in the latticepublic void computeNodePosteriors(float languageModelWeight, boolean useAcousticScoresOnly)
languageModelWeight
- the language model weight that was used
in generating the scores in the latticeuseAcousticScoresOnly
- use only the acoustic scores to compute
the posteriors, ignore the language weight and scorespublic boolean isEquivalent(Lattice other)
other
- the Lattice to compare this Lattice against
public static void main(java.lang.String[] args)
args
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |