SWIlanguageModel n-gram
Note: Information on this feature is provided for backwards compatibility.
You can use n-gram grammars to apply language model weights to SRGS grammars. This is done in the SRGS grammar with a <meta> element that specifies the desired n-gram grammar; for example:
<meta name="SWIlanguageModel" content="trigramu.xml"/>
When an n-gram grammar is used for this purpose, it is known as a SWIlanguageModel n-gram and its syntax differs from the n-gram grammars described elsewhere. Guidelines for this special n-gram:
- SWIlanguageModel n-grams use the <lexicon> instead of <vocab>, and (unlike <vocab>) the <lexicon> tag cannot use <ruleref> to import other SRGS rules using the uri attribute.
- This grammar does not support SRGS pronunciation dictionaries.
- This n-gram can include the use of a Unigram Class, specified by the <import> tag. See Example (trigramu.xml).
- The <import> element may only reference unigram n-gram grammars.
- The imported unigram n-gram grammars cannot use <ruleref> to import SRGS rules or other n-grams.
- The import attribute must be of the form name#CLASS where name is the name attribute from an import and CLASS matches a rule in the SRGS grammar.
- The CLASS rule in the SRGS must have the attribute SWIListClass="1".
- This n-grams ruleref's may only reference alias imports specified with the <import> element.

<?xml version='1.0' encoding='UTF-8'?>
<grammar xml:lang="en-US" version="1.0" root="ROOT"
tag-format="swi-semantics/1.0"
xmlns="http://www.w3.org/2001/06/grammar"
mode="voice">
<meta name="SWIlanguageModel" content="trigramu.xml"/>
<rule id="ROOT" scope="public">
<item repeat="1-">
<one-of>
<item>elephants</item>
<item>like</item>
<item>eating</item>
<item> <ruleref uri="#MY_CLASS"/> </item>
</one-of>
</item>
</rule>
<rule id="MY_CLASS" SWI_listClass="1">
<one-of>
<item>apple</item>
<item>pear</item>
<item>plums</item>
</one-of>
</rule>
</grammar>

<?xml version='1.0' encoding="UTF-8"?>
<N-Gram>
<!-- SWIlanguageModel uses lexicon instead of vocab -->
<lexicon>
<token index="1">apple</token>
<token index="2">pear</token>
<token index="3">plums</token>
</lexicon>
<tree>
<node>3 14</node>
<node>1 2</node>
<node>2 4</node>
<node>3 8</node>
</tree>
</N-Gram>

<?xml version='1.0' encoding="UTF-8"?>
<N-Gram>
<import uri="unigram.xml" name="uni"/>
<lexicon>
<token index="1">-pau-</token>
<token index="2">elephants</token>
<token index="3">like</token>
<token index="4">eating</token>
<!-- Import a Unigram Class -->
<token index="5"><ruleref import="uni7#MY_CLASS"/></token>
<token index="6">-pau2-</token>
</lexicon>
<tree>
<node>4 210</node>
<node>1 2 110</node> <!-- "-pau-" -->
<node>2 1 100</node> <!-- "-pau- elephants" -->
<node>3 50</node> <!-- "-pau- elephants like" -->
<node>2 1 100</node> <!-- "elephants" -->
<node>3 50</node> <!-- "elephants like" -->
<node>3 1 50</node> <!-- "like" -->
<node>4 1 50</node> <!-- "like eating" -->
<node>5 25</node> <!-- "like eating MY_CLASS" -->
<node>4 1 50</node> <!-- "eating" -->
<node>5 1 25</node> <!-- "eating MY_CLASS" -->
<node>6 25</node> <!-- "eating MY_CLASS -pau2-" -->
</tree>
</N-Gram>