SrgsOneOf コンストラクター

定義

SrgsOneOf クラスの新しいインスタンスを作成します。

オーバーロード

名前 説明
SrgsOneOf()

SrgsOneOf クラスの新しいインスタンスを初期化します。

SrgsOneOf(SrgsItem[])

SrgsOneOf オブジェクトの配列からSrgsItem クラスの新しいインスタンスを初期化します。

SrgsOneOf(String[])

SrgsOneOf オブジェクトの配列からString クラスの新しいインスタンスを初期化します。

注釈

String オブジェクトの配列、SrgsItem オブジェクトの配列、または空のリストから、SrgsOneOf クラスのインスタンスを構築できます。 代替の一覧でStringオブジェクトではなくSrgsItemオブジェクトを使用すると、MinRepeatMaxRepeatRepeatProbabilityWeightなど、リスト内の各項目にSrgsItemのプロパティを適用できます。

SrgsOneOf()

ソース:
SrgsOneOf.cs
ソース:
SrgsOneOf.cs
ソース:
SrgsOneOf.cs
ソース:
SrgsOneOf.cs

SrgsOneOf クラスの新しいインスタンスを初期化します。

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

次の例では、 SrgsOneOf 要素を使用して、国/地域名を含む SrgsItem 要素のリストを作成します。その中の 1 つを使用して、含まれる語句を認識できます。 次に、結果として得られる SrgsOneOf オブジェクトの 1 つを、ヨーロッパおよび南アメリカの国/地域のそれぞれのルールに追加します。 さらに、この例では、 SrgsOneOf オブジェクトを使用して、 ruleEuroperuleSAmerica へのルール参照を 2 つの代替候補の一覧にグループ化します。そのうちの 1 つは、音声入力を認識するために使用できます。

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

適用対象

SrgsOneOf(SrgsItem[])

ソース:
SrgsOneOf.cs
ソース:
SrgsOneOf.cs
ソース:
SrgsOneOf.cs
ソース:
SrgsOneOf.cs

SrgsOneOf オブジェクトの配列からSrgsItem クラスの新しいインスタンスを初期化します。

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())

パラメーター

items
SrgsItem[]

追加する代替項目。

例外

itemsnullです。

items配列内のすべての要素がnull

次の例では、"A nation that has the world Cup is" という語句を認識し、その後にワールドカップで優勝した国/地域の名前を認識する文法を作成します。 WorldCupWinnerという名前のパブリック ルールが作成されます。 次に、新しいSrgsItem オブジェクトの配列を含むSrgsOneOfオブジェクトを使用して、2 つのSrgsRule オブジェクトを作成します。 この例で生成される文法については、 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;
}

適用対象

SrgsOneOf(String[])

ソース:
SrgsOneOf.cs
ソース:
SrgsOneOf.cs
ソース:
SrgsOneOf.cs
ソース:
SrgsOneOf.cs

SrgsOneOf オブジェクトの配列からString クラスの新しいインスタンスを初期化します。

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())

パラメーター

items
String[]

追加する代替項目。

例外

itemsnullです。

items配列内のすべての要素がnull

次の例では、"A nation that has the world Cup is" という語句を認識し、その後にワールドカップで優勝した国/地域の名前を認識する文法を作成します。 この例では、 SrgsOneOf 要素を使用して、 String オブジェクトの配列から許容される国/地域名のリストを作成します。 次に、結果として得られる SrgsOneOf オブジェクトの 1 つを、ヨーロッパおよび南アメリカの国/地域のそれぞれのルールに追加します。

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

適用対象