Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you get the recognition, the SPPHRASE data associated with the recognition contains the subrules and property data and where they occur in the recognition.</p> <p>So, if you had a rule or property tag for 'Name', you could find the words associated with 'Name'. </p> <p>For example, given your grammar </p> <pre><code>&lt;GRAMMAR LANGID="409"&gt; &lt;RULE NAME="SOUNDLOG" TOPLEVEL="ACTIVE"&gt; &lt;OPT&gt; &lt;DICTATION MAX="INF"/&gt; &lt;/OPT&gt; &lt;L&gt; &lt;P&gt;name&lt;/P&gt; &lt;/L&gt; &lt;OPT&gt; &lt;DICTATION MAX="INF"/&gt; &lt;/OPT&gt; &lt;/RULE&gt; &lt;/GRAMMAR&gt; </code></pre> <p>if you change it to </p> <pre><code>&lt;GRAMMAR LANGID="409"&gt; &lt;RULE NAME="SOUNDLOG" TOPLEVEL="ACTIVE"&gt; &lt;OPT&gt; &lt;DICTATION MAX="INF"/&gt; &lt;/OPT&gt; &lt;L PROPNAME='name'&gt; &lt;P VAL='name'&gt;name&lt;/P&gt; &lt;/L&gt; &lt;OPT&gt; &lt;DICTATION MAX="INF"/&gt; &lt;/OPT&gt; &lt;/RULE&gt; &lt;/GRAMMAR&gt; </code></pre> <p>you could find the words that correspond to 'name' like this:</p> <pre><code>HRESULT OnRecognition(ISpRecoResult* pResult) { SPPHRASE *pPhrase; HRESULT hr = pResult-&gt;GetPhrase(&amp;pPhrase); if (SUCCEEDED(hr)) { const SPPHRASEPROPERTY pProp = FindProperty(pPhrase-&gt;pProperty, L"name"); if (pRule) { LPWSTR text(NULL); hr = pResult-&gt;GetText(pProp-&gt;ulFirstElement, pProp-&gt;ulCountOfElements, TRUE, &amp;text, NULL); if (SUCCEEDED(hr)) { // do something with text ::CoTaskMemFree(text); } } } return hr; } const SPPHRASEPROPERTY* FindProperty(const SPPHRASEPROPERTY* pProp, LPCWSTR what) const { while (pProp!=NULL) { if (pProp-&gt;pFirstChild != NULL) { const SPPHRASEPROPERTY* pFoundProp = FindRule(pProp-&gt;pFirstChild, what); if (pFoundProp) { return pFoundProp; } } if (pProp-&gt;pszName != NULL &amp;&amp; wcsstr(pProp-&gt;pszName, what) != NULL) { return pProp; } pProp = pProp-&gt;pNextSibling; } return NULL; } </code></pre> <p>This code looks specifically for the text covered by the property. However, it's often better to use the val attributes to identify items without binding your code explicitly to the grammar. This allows you to tweak the grammar (or add equivalent values) without changing your code. To use the values, simply use the SPPHRASEPROPERTY.pszValue or vValue fields after fetching the property (instead of using ISpPhrase::GetText).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload