SrgsOneOf Constructor (SrgsItem[])

Initializes a new instance of the SrgsOneOf class, specifying one or more alternative items in the passed SrgsItem array.

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

Syntax

'Declaration




Parameters

  • items
    An array of type SrgsItem. Each member of the array represents the contents of a single SrgsItem element.

Exceptions

Exception type Condition
ArgumentNullException

items is null.

Any element in the items array is null.

Example

The following example creates a grammar that recognizes the phrase "A nation that has won the World Cup is" followed by the name of a country that has won the World Cup. It creates a public rule named WorldCupWinner. It then creates two SrgsRule elements using arrays of SrgsOneOf elements and adds them as rule references to WorldCupWinner. To see the grammar that this example generates, see SrgsRule Constructor(String, SrgsElement[]).

public void WorldSoccerWinners ()
{
  SrgsDocument srgsGrammar = new SrgsDocument ();
  SrgsRule rootRule = new SrgsRule ("WorldCupWinner");

  rootRule.Scope = SrgsRuleScope.Public;

  // Add the introduction
  rootRule.Elements.Add (new SrgsItem ("A nation that has won the world cup is"));

  // Create the rootRule for the European nations
  SrgsOneOf oneOfEurope = new SrgsOneOf (new SrgsItem ("England"), new SrgsItem ("France"), new SrgsItem ("Germany"), new SrgsItem ("Italy"));
  SrgsRule ruleEurope = new SrgsRule ("EuropeanNations", oneOfEurope);

  // Create the rootRule for the South American nations
  SrgsOneOf oneOfSAmerica = new SrgsOneOf (new SrgsItem ("Argentina"), new SrgsItem ("Brazil"), new SrgsItem ("Uruguay"));
  SrgsRule ruleSAmerica = new SrgsRule ("SouthAmericanNations", oneOfSAmerica);

  // Add both rules to root list through a 'one of'
  rootRule.Elements.Add (new SrgsOneOf (new SrgsItem (new SrgsRuleRef (ruleEurope)), new SrgsItem (new SrgsRuleRef (ruleSAmerica))));

  // Add all the rules to the grammar
  srgsGrammar.Rules.Add (rootRule, ruleEurope, ruleSAmerica);
  srgsGrammar.Root = rootRule;
}

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

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