I have a sapi grammar as
<rule id="root">
<item repeat="0-">
<ruleref uri="#digit"></ruleref>
</item>
</rule>
<rule id="digit">
<one-of>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>0</item>
</one-of>
</rule>
I want equivalent of dynamic loading of grammar can anyone helpme on this?
I have tried
SPSTATEHANDLE hRule;
hr = cpGrammar->GetRule(L"digit", NULL, SPRAF_TopLevel | SPRAF_Active, TRUE,&hRule);
hr = cpGrammar->AddWordTransition(hRule, NULL, L"1", NULL, SPWT_LEXICAL, 1, NULL);
hr = cpGrammar->AddWordTransition(hRule, NULL, L"2", NULL, SPWT_LEXICAL, 1, NULL);
hr = cpGrammar->AddWordTransition(hRule, NULL, L"3", NULL, SPWT_LEXICAL, 1, NULL);
hr = cpGrammar->AddWordTransition(hRule, NULL, L"4", NULL, SPWT_LEXICAL, 1, NULL);
hr = cpGrammar->AddWordTransition(hRule, NULL, L"5", NULL, SPWT_LEXICAL, 1, NULL);
hr = cpGrammar->AddWordTransition(hRule, NULL, L"6", NULL, SPWT_LEXICAL, 1, NULL);
hr = cpGrammar->AddWordTransition(hRule, NULL, L"7", NULL, SPWT_LEXICAL, 1, NULL);
hr = cpGrammar->AddWordTransition(hRule, NULL, L"8", NULL, SPWT_LEXICAL, 1, NULL);
hr = cpGrammar->AddWordTransition(hRule, NULL, L"9", NULL, SPWT_LEXICAL, 1, NULL);
hr = cpGrammar->AddWordTransition(hRule, NULL, L"0", NULL, SPWT_LEXICAL, 1, NULL);
hr = cpGrammar->Commit(NULL);
hr = cpGrammar->SetGrammarState(SPGS_ENABLED);
It doesnt work for me , am I doing the right thing?
Reviewed some code that built dynamic grammars, and I'm pretty sure you need
SPRAF_Dynamic
along withSPRAF_TopLevel | SPRAF_Active
. (At least, the code I wrote used that.)