LVParseTree_CreateTerminalIteratorBegin and

LVParseTree_CreateTerminalIteratorEnd

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

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.

  1. H_PARSE_TREE_TERMINAL_ITR Itr;
  2. H_PARSE_TREE_TERMINAL_ITR End;
  3. H_PARSE_TREE_NODE Node;
  4.  
  5. Itr = LVParseTree_CreateTerminalIteratorBegin(Tree);
  6. End = LVParseTree_CreateTerminalIteratorEnd(Tree);
  7.  
  8. while (!LVParseTree_TerminalIterator_AreEqual(Itr,End))
  9. {
  10. Node = LVParseTree_TerminalIterator_GetNode(Itr);
  11. printf("\"%s\":(%i)\n",LVParseTree_Node_GetText(Node),
  12. LVParseTree_Node_GetScore(Node));
  13. LVParseTree_TerminalIterator_Advance(Itr);
  14. }
  15.  
  16. printf("\n");
  17.  
  18. LVParseTree_TerminalIterator_Release(Itr);
  19. LVParseTree_TerminalIterator_Release(End);
  20.  
  21. // Note: Node handles don't get released; They are part of the tree,
  22. // 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

© 2012 LumenVox LLC. All rights reserved.