SPPHRASERULE
SPPHRASERULE contains the information for a rule in a grammar result. SAPI uses the pFirstChild and pNextSibling pointers to represent the parse tree. SPPHRASE.Rule is the root node of the parse tree.
struct tagSPPHRASERULE
{
LPCWSTR *pszName;
ULONG ulId;
ULONG ulFirstElement;
ULONG ulCountOfElements;
const SPPHRASERULE *pNextSibling;
const SPPHRASERULE *pFirstChild;
float SREngineConfidence;
signed char Confidence;
};
Members
- pszName
- Name of this rule (in Speech Text Grammar Format set using <RULE NAME="MyName">).
- ulId
- ID of this rule (set using <RULE ID="123">).
- ulFirstElement
- The index of the first spoken element (word) of this rule.
- ulCountOfElements
- Number of spoken elements (words) spanned by this rule.
- pNextSibling
- Pointer to the next sibling in the parse tree.
- pFirstChild
- Pointer to the first child node in the parse tree.
- SREngineConfidence
- Confidence for this rule computed by the SR engine. The value is engine dependent and not standardized across multiple SR engines.
- Confidence
- Confidence for this rule computed by SAPI. The value is either SP_LOW_CONFIDENCE, SP_NORMAL_CONFIDENCE, or SP_HIGH_CONFIDENCE.
Remarks
It is sometimes possible for ulFirstElement to have a value that is larger than the largest possible index for a recognized phrase. This can happen when a rule that can match zero elements is triggered at the end of a phrase. The following example shows a situation for which ulFirstElement can have a value that is out of range for the phrase.
The SRGS rule definitions that follow can match two input phrases: "one large drink" and "one large drink please". If a user speaks the phrase "one large drink", the value of ulCountOfElements for rule1 is 3, the number of words in the phrase. In contrast, the value of ulCountOfElements for rule2 is 0, because this rule matched no words in the input phrase, and the value of ulFirstElement for rule2 is 3, the index that is one higher than that of the last word in the input phrase. For a phrase with three words, the valid indexes are 0, 1, and 2.
<rule; id="top" scope="public">
<ruleref; uri ="#rule1">
<ruleref; uri ="#rule2">
</rule>
<rule; id="rule1" scope="private">
<item;>one large drink</item>
</rule>
<rule; id="rule2" scope="private">
<item; repeat="0-" repeat-prob="0.1">please;</item>
</rule>