我有一个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);这对我不起作用,我做的是对的吗?
发布于 2013-09-19 13:58:04
回顾了一些构建动态语法的代码,我非常确定您需要使用SPRAF_Dynamic和SPRAF_TopLevel | SPRAF_Active。(至少,我编写的代码使用了这一点。)
https://stackoverflow.com/questions/18803062
复制相似问题