Język

SrgsOneOf Konstruktory

Definicja

Tworzy nowe wystąpienie SrgsOneOf klasy.

Przeciążenia

Nazwisko Opis
SrgsOneOf()

Inicjuje nowe wystąpienie klasy SrgsOneOf.

SrgsOneOf(SrgsItem[])

Inicjuje nowe wystąpienie SrgsOneOf klasy z tablicy SrgsItem obiektów.

SrgsOneOf(String[])

Inicjuje nowe wystąpienie SrgsOneOf klasy z tablicy String obiektów.

Uwagi

Możesz utworzyć wystąpienie SrgsOneOf klasy z tablicy obiektów, z tablicy StringSrgsItem obiektów lub jako pustą listę. Użycie SrgsItem obiektów zamiast String obiektów na liście alternatyw umożliwia zastosowanie właściwości SrgsItem do każdego elementu na liście, takich jak MinRepeat, MaxRepeat, RepeatProbabilityi Weight.

SrgsOneOf()

Źródło:
SrgsOneOf.cs
Źródło:
SrgsOneOf.cs
Źródło:
SrgsOneOf.cs
Źródło:
SrgsOneOf.cs

Inicjuje nowe wystąpienie klasy SrgsOneOf.

public:
 SrgsOneOf();
public SrgsOneOf();
Public Sub New ()

Przykłady

W poniższym przykładzie użyto SrgsOneOf elementu do kompilowania list SrgsItem elementów zawierających nazwy kraju/regionu, które mogą służyć do rozpoznawania zawierającej frazę. W tym przykładzie dodamy jeden z wynikowych SrgsOneOf obiektów do odpowiednich reguł dla krajów/regionów Europejskich i Południowoamerykańskich. Ponadto w przykładzie użyto SrgsOneOf obiektu do grupowania odwołań do reguł i ruleEuroperuleSAmerica do listy dwóch alternatyw, z których jeden może służyć do rozpoznawania wypowiedzianych danych wejściowych.

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;
}

Zobacz też

Dotyczy

SrgsOneOf(SrgsItem[])

Źródło:
SrgsOneOf.cs
Źródło:
SrgsOneOf.cs
Źródło:
SrgsOneOf.cs
Źródło:
SrgsOneOf.cs

Inicjuje nowe wystąpienie SrgsOneOf klasy z tablicy SrgsItem obiektów.

public:
 SrgsOneOf(... cli::array <System::Speech::Recognition::SrgsGrammar::SrgsItem ^> ^ items);
public SrgsOneOf(params System.Speech.Recognition.SrgsGrammar.SrgsItem[] items);
new System.Speech.Recognition.SrgsGrammar.SrgsOneOf : System.Speech.Recognition.SrgsGrammar.SrgsItem[] -> System.Speech.Recognition.SrgsGrammar.SrgsOneOf
Public Sub New (ParamArray items As SrgsItem())

Parametry

items
SrgsItem[]

Elementy alternatywne do dodania.

Wyjątki

Parametr items ma wartość null.

Każdy element w tablicy items to null.

Przykłady

W poniższym przykładzie tworzona jest gramatyka, która rozpoznaje frazę "Naród, który wygrał Puchar Świata" i nazwę kraju/regionu, który wygrał Mistrzostwa Świata. Tworzy regułę publiczną o nazwie WorldCupWinner. Następnie tworzy dwa SrgsRule obiekty przy użyciu SrgsOneOf obiektów zawierających tablice nowych SrgsItem obiektów. Aby wyświetlić gramatykę wygenerowaną w tym przykładzie, zobacz SrgsRule.

 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;
}

Zobacz też

Dotyczy

SrgsOneOf(String[])

Źródło:
SrgsOneOf.cs
Źródło:
SrgsOneOf.cs
Źródło:
SrgsOneOf.cs
Źródło:
SrgsOneOf.cs

Inicjuje nowe wystąpienie SrgsOneOf klasy z tablicy String obiektów.

public:
 SrgsOneOf(... cli::array <System::String ^> ^ items);
public SrgsOneOf(params string[] items);
new System.Speech.Recognition.SrgsGrammar.SrgsOneOf : string[] -> System.Speech.Recognition.SrgsGrammar.SrgsOneOf
Public Sub New (ParamArray items As String())

Parametry

items
String[]

Elementy alternatywne do dodania.

Wyjątki

Parametr items ma wartość null.

Każdy element w tablicy items to null.

Przykłady

W poniższym przykładzie tworzona jest gramatyka, która rozpoznaje frazę "Naród, który wygrał Puchar Świata" i nazwę kraju/regionu, który wygrał Mistrzostwa Świata. W tym przykładzie użyto elementu do utworzenia SrgsOneOf list dopuszczalnych nazw krajów/regionów z tablicy String obiektów. W tym przykładzie dodamy jeden z wynikowych SrgsOneOf obiektów do odpowiednich reguł dla krajów/regionów Europejskich i Południowoamerykańskich.

public void WorldSoccerWinners ()
{
    // Create a grammar from an SRGSDocument, create a new rule
  // and set its scope to public.
  SrgsDocument srgsGrammar = 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 string[] {"England","France","Germany","Italy"});
  SrgsRule ruleEurope = (new SrgsRule("EuropeanNations", new SrgsElement[] {oneOfEurope}));

  // Create the rule for the South American nations.
  SrgsOneOf oneOfSAmerica = new SrgsOneOf (new string[] {"Argentina","Brazil","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 grammar and make winnerRule
  // the root rule of the grammar.
  srgsGrammar.Rules.Add (new SrgsRule[] {winnerRule, ruleEurope, ruleSAmerica});
  srgsGrammar.Root = winnerRule;
}

Zobacz też

Dotyczy