Rss Categories

LVParseTree::TerminalsBegin and LVParseTree::TerminalsEnd

Reference Number: AA-00976 Views: 7215 0 Rating/ Voters

TerminalsBegin and TerminalsEnd 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 engine heard a speaker say to match a grammar, in the order that the engine heard those words.


  • LVParseTree::TerminalIterator TerminalsBegin()

    LVParseTree::TerminalIterator TerminalsEnd()


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

  1. LVParseTree::TerminalIterator Itr = Tree.TerminalsBegin();
  2. LVParseTree::TerminalIterator End = Tree.TerminalsEnd();
  4. for (; Itr != End; ++Itr)
  5. {
  6. cout << "\"" << Itr->Text() << "\":(" << Itr->Score() << ") ";
  7. }
  8. cout << endl;

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

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

See Also