LVParseTree Summary

 A ParseTree represents a sentence diagram of speech engine output, according to the SRGS grammar that was matched.  Information about the tree is accessed through iterators.

The function call LVCA_GetParseTreeHandle retrieves a pointer of type H_PARSE_TREE.  

BOOL LVCA_GetParseTreeHandle(HANDLE hCA, LONG ParseIndex, void ** Tree) ;

All functions using the H_PARSE_TREE can be found in the header <LV_SRE_ParseTree.h>.  The help documentation can be found in the LumenVox Speech Rec API help document.

Cast the void pointer to a H_PARSE_TREE Variable Type.

void* Tree;

LONG count;

LVCA_GetNumberOfSRGSParses(hCA, &count);

for(int i = 0; i < count; i++)

{

LVCA_GetParseTreeHandle(hCA, 1, tree)

H_PARSE_TREE ptree = (H_PARSE_TREE) Tree

PrintTags(ptree);

PrintTree(ptree);

LVParseTree_Release(ptree);

}

For the examples below the active grammar will be:

#ABNF 1.0;

language en-US;

mode voice;

tag-format <XML>; //a made up tag format.

root $PhoneNumber;

$Digit = one {1} | two {2} | three {3} | four {4} | five {5} |

         six {6} | seven {7} | eight {8} | nine {9} | (zero | oh) {0};         

$AreaCode = [area code | one] {<AREA_CODE>} $Digit<3> {</AREA_CODE>};

$PhoneNumber = [$AreaCode] {<PHONE>} $Digit<7> {</PHONE>};

And the decoded sentence will be "area code eight five eight seven oh seven oh seven oh seven"

Example 1

void PrintTags(H_PARSE_TREE Tree)

{

H_PARSE_TREE_NODE N;

H_PARSE_TREE_ITR Itr;

char buffer[1024];

Itr = LVParseTree_CreateIteratorBegin(Tree);

for (; !LVParseTree_Iterator_IsPastEnd(Itr); LVParseTree_Iterator_Advance(Itr))

{

N = LVParseTree_Iterator_GetNode(Itr);

if(LVParseTree_Node_IsTag(N))

{

printf("%s ", LVParseTree_Node_GetLabel(N));

}

}

LVParseTree_Iterator_Release(Itr);

}

Example 1 result:

"<AREA_CODE> 8 5 8 </AREA_CODE> <PHONE> 7 0 7 0 7 0 7 </PHONE>"

Example 2

void PrintNode(H_PARSE_TREE_NODE N)

  

{

     H_PARSE_TREE_CHILDREN_ITR I;

     int i;

     for (i = 0; i < LVParseTree_Node_GetLevel(N); ++i)

          printf("     ");

     

     if (LVParseTree_Node_IsTerminal(N))

          printf("\"%s\"\n",LVParseTree_Node_GetText(N));

     if (LVParseTree_Node_IsTag(N))

          printf("{ %s }\n",LVParseTree_Node_GetText(N));

     if (LVParseTree_Node_IsRule(N))

     {

          printf("$%s:\n",LVParseTree_Node_GetRuleName(N));

          I = LVParseTree_Node_CreateChildrenIterator(N);

          while (!LVParseTree_ChildrenIterator_IsPastEnd(I))

          {

               PrintNode(LVParseTree_ChildrenIterator_GetNode(I));

               LVParseTree_ChildrenIterator_Advance(I);

          }

          LVParseTree_ChildrenIterator_Release(I);

     }

}

void PrintTree(H_PARSE_TREE Tree)

{

     PrintNode(LVParseTree_GetRoot(Tree));

}

Example 2 Result

$PhoneNumber:

     $AreaCode:

          "AREA"

          "CODE"

          { <AREA_CODE> }

          $Digit:

               "EIGHT"

               { 8 }

          $Digit:

               "FIVE"

               { 5 }

          $Digit:

               "EIGHT"

               { 8 }

          { </AREA_CODE> }

     { <PHONE> }

     $Digit:

          "SEVEN"

          { 7 }

     $Digit:

          "OH"

          { 0 }

     $Digit:

          "SEVEN"

          { 7 }

     $Digit:

          "OH"

          { 0 }

     $Digit:

          "SEVEN"

          { 7 }

     $Digit:

          "OH"

          { 0 }

     $Digit:

          "SEVEN"

          { 7 }

     { </PHONE> }

Additional Information

LumenVox Speech Rec API

LVParseTree C API Functions

LVParseTree_Node C API


Complete Help Topic List | Speech Platform Product Information