我有一个 sapi 语法
<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>
我想要相当于动态加载语法,有人可以帮我吗?
我努力了
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);
它对我不起作用,我做对了吗?