Initializes a new instance of the SrgsOneOf class.
Namespace:
Microsoft.Speech.Recognition.SrgsGrammar
Assembly:
Microsoft.Speech (in Microsoft.Speech.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Sub New |
Visual Basic (Usage) |
---|
Dim instance As New SrgsOneOf() |
C# |
---|
public SrgsOneOf() |
Examples
The following example uses the SrgsOneOf element to build lists of SrgsItem elements containing country names, any one of which may be used to recognize the containing phrase. The example then adds one of the resulting SrgsOneOf objects to their respective rules for European countries and South American countries. Further on, the example uses the SrgsOneOf object to group rule references to ruleEurope and ruleSAmerica into a list of two alternatives, either one of which may be used to recognize spoken input.
Copy Code | |
---|---|
public void WorldSoccerWinners () { // Create an SrgsDocument, create a new rule // and set its scope to public. SrgsDocument document = new SrgsDocument(); SrgsRule winnerRule = new SrgsRule("WorldCupWinner"); winnerRule.Scope = SrgsRuleScope.Public; // Add the introduction. winnerRule.Elements.Add(new SrgsItem("A nation that has won the world cup is: ")); // Create the rule for the European nations. SrgsOneOf oneOfEurope = new SrgsOneOf(new SrgsItem[] {new SrgsItem("England"), new SrgsItem("France"), new SrgsItem("Germany"), new SrgsItem("Italy")}); SrgsRule ruleEurope = (new SrgsRule("EuropeanNations", new SrgsElement[] {oneOfEurope})); // Create the rule for the South American nations. SrgsOneOf oneOfSAmerica = new SrgsOneOf(new SrgsItem[] {new SrgsItem("Argentina"), new SrgsItem("Brazil"), new SrgsItem("Uruguay")}); SrgsRule ruleSAmerica = (new SrgsRule("SouthAmericanNations", new SrgsElement[] {oneOfSAmerica})); // Add references to winnerRule for ruleEurope and ruleSAmerica. winnerRule.Elements.Add(new SrgsOneOf(new SrgsItem[] {(new SrgsItem (new SrgsRuleRef(ruleEurope))), new SrgsItem(new SrgsRuleRef(ruleSAmerica))})); // Add all the rules to the document and make winnerRule // the root rule of the document. document.Rules.Add(new SrgsRule[] {winnerRule, ruleEurope, ruleSAmerica}); document.Root = winnerRule; } |