다음을 통해 공유


SrgsOneOf 생성자

정의

SrgsOneOf 클래스의 새 인스턴스를 만듭니다.

오버로드

SrgsOneOf()

SrgsOneOf 클래스의 새 인스턴스를 초기화합니다.

SrgsOneOf(SrgsItem[])

SrgsOneOf 개체의 배열에서 SrgsItem 클래스의 새 인스턴스를 초기화합니다.

SrgsOneOf(String[])

SrgsOneOf 개체의 배열에서 String 클래스의 새 인스턴스를 초기화합니다.

설명

개체 배열, 개체 배열 또는 빈 목록으로 클래스의 StringSrgsItem instance SrgsOneOf 생성할 수 있습니다. 대체 목록에서 개체 대신 String 개체를 사용하면 SrgsItem 의 속성을 SrgsItem 목록의 각 항목(예: MinRepeat, , MaxRepeatRepeatProbabilityWeight)에 적용할 수 있습니다.

SrgsOneOf()

Source:
SrgsOneOf.cs
Source:
SrgsOneOf.cs
Source:
SrgsOneOf.cs
Source:
SrgsOneOf.cs

SrgsOneOf 클래스의 새 인스턴스를 초기화합니다.

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

예제

다음 예제에서는 요소를 사용하여 SrgsOneOf 국가/지역 이름을 포함하는 요소 목록을 SrgsItem 작성합니다. 이 중 하나를 사용하여 포함된 구를 인식할 수 있습니다. 그런 다음, 결과 SrgsOneOf 개체 중 하나를 유럽 및 남미 국가/지역에 대한 해당 규칙에 추가합니다. 또한 이 예제에서는 개체를 SrgsOneOf 사용하여 및 에 대한 규칙 참조를 ruleEuroperuleSAmerica 두 가지 대안 목록으로 그룹화합니다. 그 중 하나는 음성 입력을 인식하는 데 사용될 수 있습니다.

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[])

Source:
SrgsOneOf.cs
Source:
SrgsOneOf.cs
Source:
SrgsOneOf.cs
Source:
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[]

추가할 대체 항목입니다.

예외

items이(가) null인 경우

items 배열의 요소가 null인 경우

예제

다음 예제에서는 "월드컵에서 우승한 국가는 입니다"라는 문구와 월드컵 우승 국가/지역의 이름을 인식하는 문법을 만듭니다. 라는 WorldCupWinner공용 규칙을 만듭니다. 그런 다음 새 SrgsItem 개체의 배열을 포함하는 개체를 사용하여 SrgsOneOfSrgsRule 개의 개체를 만듭니다. 이 예제에서 생성하는 문법을 보려면 를 참조하세요 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[])

Source:
SrgsOneOf.cs
Source:
SrgsOneOf.cs
Source:
SrgsOneOf.cs
Source:
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[]

추가할 대체 항목입니다.

예외

items이(가) null인 경우

items 배열의 요소가 null인 경우

예제

다음 예제에서는 "월드컵에서 우승한 국가는 입니다"라는 문구와 월드컵 우승 국가/지역의 이름을 인식하는 문법을 만듭니다. 이 예제에서는 요소를 사용하여 SrgsOneOf 개체 배열 String 에서 허용되는 국가/지역 이름 목록을 작성합니다. 그런 다음, 결과 SrgsOneOf 개체 중 하나를 유럽 및 남미 국가/지역에 대한 해당 규칙에 추가합니다.

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

추가 정보

적용 대상