为UWP创建新的语法xml

时间:2018-12-03 15:23:51

标签: c# xml uwp

我正在尝试为Microsoft语音识别创建我的个人语法。

这就是我所做的:

<?xml version="1.0" encoding="utf-8" ?>
 <grammar
  version="1.0" mode="voice" root="commands"
  xml:lang="en-EN" tag-format="semantics/1.0"
  xmlns="http://www.w3.org/2001/06/grammar">

 <rule id="commands">
  <one-of>
   <item>
    <ruleref uri="#open"/>
  </item>
  <item>
    <ruleref uri="#areas"/>
  </item>
  <item>
    <ruleref uri="#zones"/>
  </item>
</one-of>

我的公开规则很简单:

<rule id="open">
 <one-of>
    <item>
        <one-of>
            <item>open</item>
        </one-of>
        <tag> out="open"; </tag>
    </item>
 </one-of>
</rule>

现在,我想创建一个涉及两个主要规则 zone areas 的新规则。因此,基本上,我想说“区域1区域5”(因此关键字区域和区域带有数字),语音识别能够理解整个短语“区域1区域5”。有可能吗?

谢谢

1 个答案:

答案 0 :(得分:1)

我有一个样本:

    <rule id="commands" scope="public">      
        <one-of>
            <item><ruleref uri="#open" /></item>
            <item><tag>out.result=""; </tag> <ruleref uri="#zonearea" /> <tag> out.result=rules.latest();</tag> </item>         
    </one-of>
  </rule>

  <rule id="open">
        <one-of>
        <item>
        <one-of>
            <item>open</item>
        </one-of>
        <tag> out="open"; </tag>
        </item>
        </one-of>
    </rule>

    <rule id="zonearea" scope="private">
        <item> ZONE </item>
        <item>
            <ruleref uri="#Number"/><tag> out = "ZONE " +rules.Number; </tag>
        </item>
        <item> AREA </item>
        <item>
            <ruleref uri="#Number"/>
            <tag> out = " AREA " + rules.latest();</tag>
        </item>
    </rule>

    <rule id="Number" scope = "private">
        <one-of>
        <item> one <tag> out ="1"; </tag></item>
      <item> two <tag> out ="2"; </tag></item>
      <item> three <tag> out ="3"; </tag></item> 
        </one-of>
    </rule>