I found this on google while searching on some information on SAPI identifying phrases. This example shows if there is only one property in the rule. So what if there are 2 or more properties in that rule? How would one go about writing the code for this? I am still confused about SAPI and trying to understand it. Any help is welcome, thanks!
The alternate method is add a property to your list tag/items [you appear to
be familiar with properties], iterate through the property tree to find the
property, and then retrieve the associated item from the property. Note if
this is the only property in your recognized rule, then it is fairly easy to
retrieve the property [no need to navigate the property tree].
For example, you could change your rule to be the following:
<RULE ID="VID_Vcs">
<L PROPNAME="NAME_LIST">
<P VAL="1">Mike </P>
<P VAL="2">Davor </P>
<P VAL="3">Kurt </P>
<P VAL="4">Steve </P>
</L>
</RULE>
Use the following code to retrieve the list item value/phrase text
SPPHRASE* pPhrase = NULL;
hr = cpRecoResult->GetPhrase(&pPhrase);
// Check hr
// Let's assume that you only have one property in your rule, so there is only one property in the property tree.
// ASSERT: NULL == pPhrase->pProperties->pNextSibling && NULL == pPhrase->pProperties->pFirstChild
// ASSERT: NULL != pPhrase->pProperties->pszName && 0 == wcscmp(pPhrase->pProperties->pszName, L"NAME_LIST")
// retrieve the list item index [e.g. 1-4], see VAL XML tags in aforementioned grammar
long lRecognizedListItemIndex = pPhrase->pProperties->vValue.lVal;
// retrieve the phrase text
hr = cpRecoResult->GetText(pPhrase->pProperties->ulFirstElement, pPhrase->pProperties->ulCOuntOfElements, FALSE, &pwszListItem, NULL);
// Check hr
// pwszListItem now contains the recognized list item
//compared to the phrase tag of the dictionary (XML)
if(SUCCEEDED (hResult)) {
if ((pPhrase->pProperties != nullptr) && (pPhrase->pProperties->pFirstChild != nullptr)){
const SPPHRASEPROPERTY* pRule = pPhrase->pProperties->pFirstChild ;
if (pRule->SREngineConfidence->confidence Threshold) {
if ( wcscmp ( L"word one", pRule->pszValue) == 0 ) {
//do stuff here
}
else if ( wcscmp ( L"word two", pRule->pszValue) == 0 ) {
//do stuff here
}
else if ( wcscmp ( L"word three", pRule->pszValue) == 0 ) {
//do stuff here
}
else if ( wcscmp ( L"word four", pRule->pszValue ) == 0) {
//do stuff
}
}
}
}