SrgsDocument Constructor ()

Initializes a new instance of the SrgsDocument class.

Namespace: Microsoft.Speech.Recognition.SrgsGrammar
Assembly: Microsoft.Speech (in microsoft.speech.dll)

Syntax

'Declaration
Public Sub New
public SrgsDocument ()
public:
SrgsDocument ()
public SrgsDocument ()
public function SrgsDocument ()

Remarks

The default constructor initializes any fields to their default values.

Example

The following example creates an SrgsDocument object and then creates a public rule named rootRule. It then creates an SrgsItem that consists of the string "A nation that has won the world cup is:", and adds this item to the Elements property of the rule. The example then creates two more rules (ruleEurope and ruleSAmerica), each of which is an SrgsOneOf object that contains three SrgsItem objects. After that, another SrgsOneOf object is created that contains SrgsRuleRef objects that refer to ruleEurope and ruleSAmerica. The new SrgsOneOf object is then added to the Elements property of rootRule. After this, all three rules (rootRule, ruleEurope, and ruleSAmerica) are added to the Rules property of SrgsDocument. Finally, the three rules are compiled into a binary representation of the grammar.

SrgsDocument document = new SrgsDocument();

SrgsRule rootRule = new SrgsRule("WorldCupWinner");
rootRule.Scope = SrgsRuleScope.Public;

rootRule.Elements.Add(new SrgsItem("A nation that has won the world cup is: "));
SrgsOneOf oneOfEurope = new SrgsOneOf(new SrgsItem("England"), new SrgsItem("France"), new SrgsItem("Germany"), new SrgsItem("Italy"));
SrgsRule ruleEurope = new SrgsRule("EuropeanNations", oneOfEurope);

SrgsOneOf oneOfSAmerica = new SrgsOneOf(new SrgsItem("Argentina"), new SrgsItem("Brazil"), new SrgsItem("Uruguay"));
SrgsRule ruleSAmerica = new SrgsRule("SouthAmericanNations", oneOfSAmerica);

rootRule.Elements.Add(new SrgsOneOf(new SrgsItem(new SrgsRuleRef(ruleEurope)), new SrgsItem(new SrgsRuleRef(ruleSAmerica))));

document.Rules.Add(rootRule, ruleEurope, ruleSAmerica);
document.Root = rootRule;

String fileName = Path.GetTempFileName();
FileStream stream = new FileStream(fileName, FileMode.Create);

SrgsGrammarCompiler.Compile(document, stream);
stream.Close();
lil

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

See Also

Reference

SrgsDocument Class
SrgsDocument Members
Microsoft.Speech.Recognition.SrgsGrammar Namespace