Share via


SrgsOneOf コンストラクター

定義

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

オーバーロード

SrgsOneOf()

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

SrgsOneOf(SrgsItem[])

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

SrgsOneOf(String[])

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

注釈

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

SrgsOneOf()

ソース:
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

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

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 です。

次の例では、"ワールドカップで優勝した国" という語句の後に、ワールドカップで優勝した国/地域の名前を認識する文法を作成します。 という名前のパブリック ルールが作成されます 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

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

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 です。

次の例では、"ワールドカップで優勝した国" という語句の後に、ワールドカップで優勝した国/地域の名前を認識する文法を作成します。 この例では、 要素を 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;
}

こちらもご覧ください

適用対象