Browse
 
Tools
Rss Categories

LVParseTree_CreateTerminalIteratorBegin and LVParseTree_CreateTerminalIteratorEnd

Reference Number: AA-00961 Views: 1157 0 Rating/ Voters

LVParseTree_CreateTerminalIteratorBegin and LVParseTree_CreateTerminalIteratorEnd provide access to the "terminals" of the tree. Terminals are the words and phrases in your grammar, so a TerminalIterator gives you access the the exact words the speech engine heard a speaker say to match a grammar, in the order that the Speech Engine heard those words.

Functions

  • H_PARSE_TREE_TERMINAL_ITR LVParseTree_CreateTerminalIteratorBegin(H_PARSE_TREE Tree)

    H_PARSE_TREE_TERMINAL_ITR LVParseTree_CreateTerminalIteratorEnd(H_PARSE_TREE Tree)

Parameter

Tree

Handle to a parse tree.

Example

The following code prints out the sentence Speech Engine heard, with a word-level confidence score attached to each word.

C code

H_PARSE_TREE_TERMINAL_ITR Itr;
H_PARSE_TREE_TERMINAL_ITR End;
H_PARSE_TREE_NODE Node;

Itr = LVParseTree_CreateTerminalIteratorBegin(Tree);
End = LVParseTree_CreateTerminalIteratorEnd(Tree);
 
while (!LVParseTree_TerminalIterator_AreEqual(Itr,End))
{
Node = LVParseTree_TerminalIterator_GetNode(Itr);
printf("\"%s\":(%i)\n",LVParseTree_Node_GetText(Node),
LVParseTree_Node_GetScore(Node));
LVParseTree_TerminalIterator_Advance(Itr);
}

printf("\n");

LVParseTree_TerminalIterator_Release(Itr);
LVParseTree_TerminalIterator_Release(End);

// Note: Node handles don't get released; They are part of the tree,
// and the tree releases them when it gets released

So if the grammar being used was the top level navigation example grammar, and the Speech Engine recognized "go back", then the output of the above code might look like:

"go":(850) "back":(901)

See Also