SrgsRuleRef 생성자

정의

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

오버로드

SrgsRuleRef(SrgsRule)

SrgsRuleRef 클래스의 새 인스턴스를 초기화하고 참조할 규칙을 지정합니다.

SrgsRuleRef(Uri)

SrgsRuleRef 클래스의 새 인스턴스를 초기화하며 참조에 대한 외부 문법 파일의 위치를 지정합니다.

SrgsRuleRef(SrgsRule, String)

참조에 대한 규칙과 의미 키를 포함하는 문자열을 지정하는 SrgsRuleRef 클래스의 새 인스턴스를 초기화합니다.

SrgsRuleRef(Uri, String)

참조에 대한 외부 문법 파일의 위치와 규칙의 식별자를 지정하는 SrgsRuleRef 클래스의 새 인스턴스를 초기화합니다.

SrgsRuleRef(SrgsRule, String, String)

참조에 대한 규칙, 의미 사전의 문자열 별칭 및 초기화 매개 변수를 지정하는 SrgsRuleRef 클래스의 새 인스턴스를 초기화합니다.

SrgsRuleRef(Uri, String, String)

외부 문법 파일의 위치, 규칙의 식별자 및 의미 사전의 문자열 별칭을 지정하는 SrgsRuleRef 클래스의 새 인스턴스를 초기화합니다.

SrgsRuleRef(Uri, String, String, String)

외부 문법 파일의 위치, 규칙의 식별자, 의미 사전의 문자열 별칭 및 초기화 매개 변수를 지정하는 SrgsRuleRef 클래스의 새 인스턴스를 초기화합니다.

SrgsRuleRef(SrgsRule)

Source:
SrgsRuleRef.cs
Source:
SrgsRuleRef.cs
Source:
SrgsRuleRef.cs

SrgsRuleRef 클래스의 새 인스턴스를 초기화하고 참조할 규칙을 지정합니다.

public:
 SrgsRuleRef(System::Speech::Recognition::SrgsGrammar::SrgsRule ^ rule);
public SrgsRuleRef (System.Speech.Recognition.SrgsGrammar.SrgsRule rule);
new System.Speech.Recognition.SrgsGrammar.SrgsRuleRef : System.Speech.Recognition.SrgsGrammar.SrgsRule -> System.Speech.Recognition.SrgsGrammar.SrgsRuleRef
Public Sub New (rule As SrgsRule)

매개 변수

rule
SrgsRule

참조할 개체입니다.

예외

rule이(가) null인 경우

예제

다음 예제에서는 라는 문구를 인식 하는 문법의 전 세계 월드컵 성공한에 국가 이름 뒤에 "가 전 세계 월드컵에 국가". 개체 winnerRuleSrgsRule 만들고 문자열 식별자를 WorldCupWinner지정한 후 예제에서는 규칙에 "월드컵에서 우승한 국가는 입니다"라는 문자열을 추가합니다. 이 예제에서는 개체를 사용하여 SrgsOneOf 유럽 국가/지역 목록과 남미 국가/지역 목록을 작성하고 각 목록을 해당 규칙 ruleEurope 또는 ruleSAmerica에 추가합니다. 이 예에서는 다음에 대 한 규칙 참조를 만듭니다 ruleEurope 하 고 ruleSAmerica 에 추가 합니다는 WorldCupWinner 규칙입니다.

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

만든된 문법에 다음과 같은 형식입니다.

<grammar version="1.0" xml:lang="en-US" xmlns="http://www.w3.org/2001/06/grammar" root="WorldCupWinner">
    <rule id="WorldCupWinner" scope="public">
        <item> A nation that has won the world cup is </item>
        <one-of>
            <item>
                <ruleref uri="#EuropeanNations" />
            </item>
            <item>
                <ruleref uri="#SouthAmericanNations" />
            </item>
        </one-of>
    </rule>
    <rule id="EuropeanNations">
        <one-of>
            <item> England </item>
            <item> France </item>
            <item> Germany </item>
            <item> Italy </item>
        </one-of>
    </rule>
    <rule id="SouthAmericanNations">
        <one-of>
            <item> Argentina </item>
            <item> Brazil </item>
            <item> Uruguay </item>
        </one-of>
    </rule>
</grammar>

설명

이 생성자는 포함하는 문법 내의 개체에 대한 SrgsRule 규칙 참조를 만듭니다. 규칙 참조를 만드는 데는 rule 요소를 외부 문법 파일에 다음 생성자 중 하나를 사용 합니다.

추가 정보

적용 대상

SrgsRuleRef(Uri)

Source:
SrgsRuleRef.cs
Source:
SrgsRuleRef.cs
Source:
SrgsRuleRef.cs

SrgsRuleRef 클래스의 새 인스턴스를 초기화하며 참조에 대한 외부 문법 파일의 위치를 지정합니다.

public:
 SrgsRuleRef(Uri ^ uri);
public SrgsRuleRef (Uri uri);
new System.Speech.Recognition.SrgsGrammar.SrgsRuleRef : Uri -> System.Speech.Recognition.SrgsGrammar.SrgsRuleRef
Public Sub New (uri As Uri)

매개 변수

uri
Uri

포함하는 문법 이외의 문법 파일 위치입니다.

예외

uri이(가) null인 경우

예제

다음 예제에서는 셔틀 service bus에 대 한 정보를 반환 하는 애플리케이션에 대 한 문법을 만듭니다. 첫 번째 방법은 GrammarUrlForRoute, 경로 지정 하 고 그래 머의 위치를 지정 하는 문자열에 추가 된 문자열을 사용 합니다. 이 문법에서 특정 규칙을 지정합니다. 메서드는 반환 된 Uri 해당 규칙에 대 한 합니다.

두 번째 CreateGrammarForRoute를 만듭니다는 SrgsDocument 라는 요소가 grammar 하 여 지정 된 규칙 참조를 사용 하 여를 Uri 에서 전달 된 GrammarUrlForRoute합니다. 변수 이름을 _route 있음을 참고 바깥쪽 클래스의 멤버 임

private Uri GrammarUrlForRoute(string route)
{
  return new Uri("http://localhost/MyBus/MyBusLocations.grxml#LocationsForRoute" + route);
}

private SrgsDocument CreateGrammarForRoute()
{
  SrgsDocument grammar = new SrgsDocument();
  grammar.Mode = SrgsGrammarMode.Voice;
  SrgsRule rule = new SrgsRule("LocationsForRoute" + _route);
  SrgsRuleRef ruleref = new SrgsRuleRef(GrammarUrlForRoute(_route));

  SrgsSemanticInterpretationTag tag = new SrgsSemanticInterpretationTag ("$.Location = $$");

  rule.Elements.Add(ruleref);
  rule.Elements.Add(tag);
  grammar.Rules.Add(rule);
  grammar.Root = rule;
  return grammar;
}

참고

_ 라는 변수에route 선언 되지 않은 이며 앞의 예제에서 정의 되지 않은 합니다. 로 선언 해야 하는 것을 String 앞에 나온 샘플 컴파일 및 실행 하기 전에 특정 버스 경로 대 한 경로 수를 포함 합니다.

설명

이 생성자는 외부 문법 파일에 대 한 규칙 참조를 만듭니다. URI를 예를 들어 참조 하는 규칙의 식별자를 포함할 수도 있습니다 http://www.contoso.com/ExternalGrammar.grxml#targetRule합니다. 경우는 uri 매개 변수는 식별자를 지정 하지 규칙을 규칙 참조를 대상 문법의 루트 규칙을 가리킵니다. 규칙 참조를 만드는 데는 SrgsRule 같은 문법 내 개체, 다음과 같은 생성자 중 하나를 사용 합니다.

추가 정보

적용 대상

SrgsRuleRef(SrgsRule, String)

Source:
SrgsRuleRef.cs
Source:
SrgsRuleRef.cs
Source:
SrgsRuleRef.cs

참조에 대한 규칙과 의미 키를 포함하는 문자열을 지정하는 SrgsRuleRef 클래스의 새 인스턴스를 초기화합니다.

public:
 SrgsRuleRef(System::Speech::Recognition::SrgsGrammar::SrgsRule ^ rule, System::String ^ semanticKey);
public SrgsRuleRef (System.Speech.Recognition.SrgsGrammar.SrgsRule rule, string semanticKey);
new System.Speech.Recognition.SrgsGrammar.SrgsRuleRef : System.Speech.Recognition.SrgsGrammar.SrgsRule * string -> System.Speech.Recognition.SrgsGrammar.SrgsRuleRef
Public Sub New (rule As SrgsRule, semanticKey As String)

매개 변수

rule
SrgsRule

참조할 개체입니다.

semanticKey
String

의미 키입니다.

예제

다음 예제에서는 항공편에 대 한 도시를 선택 하는 것에 대 한 문법을 만듭니다. 이 예제에서는 두 개의 생성 SrgsRuleRef 인스턴스를 각각 의미 키를 지정 합니다. 참조 대상 동일한 규칙 둘 다 SrgsRule 라는 개체 cities, 다른 의미 체계 키를 사용 하 여 규칙 참조에서 인식 결과 태그 지정 하지만 합니다. 의미 키 출발 도시 또는 항공권 도착 시 인식할 수 있는 도시를 식별합니다. 에 대 한 처리기를 SpeechRecognized 사용 하 여 만든 의미 값을 검색 하는 키를 사용 하는 이벤트 SrgsNameValueTag 인식 결과에서.

using System;
using System.Speech.Recognition;
using System.Speech.Recognition.SrgsGrammar;

namespace SampleRecognition
{
  class Program
  {
    static void Main(string[] args)

    // Initialize a SpeechRecognitionEngine object.
    {
      using (SpeechRecognitionEngine recognizer =
         new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US")))
      {

        // Build a rule with a list of cities, assign a semantic value to each city.
        SrgsItem chi = new SrgsItem("Chicago");
        chi.Add(new SrgsNameValueTag("ORD"));
        SrgsItem bos = new SrgsItem("Boston");
        bos.Add(new SrgsNameValueTag("BOS"));
        SrgsItem mia = new SrgsItem("Miami");
        mia.Add(new SrgsNameValueTag("MIA"));
        SrgsItem dal = new SrgsItem("Dallas");
        dal.Add(new SrgsNameValueTag("DFW"));

        SrgsOneOf cities = new SrgsOneOf(new SrgsItem[] { chi, bos, mia, dal });
        SrgsRule citiesRule = new SrgsRule("flightCities");
        citiesRule.Add(cities);

        // Build the root rule, add rule references to the cities rule.
        SrgsRule flightBooker = new SrgsRule("bookFlight");
        flightBooker.Add(new SrgsItem("I want to fly from"));
        flightBooker.Add(new SrgsRuleRef(citiesRule, "departureCity"));
        flightBooker.Add(new SrgsItem("to"));
        flightBooker.Add(new SrgsRuleRef(citiesRule, "arrivalCity"));

        // Build an SrgsDocument object from the flightBooker rule and add the cities rule.
        SrgsDocument cityChooser = new SrgsDocument(flightBooker);
        cityChooser.Rules.Add(citiesRule);

        // Create a Grammar object from the SrgsDocument and load it to the recognizer.
        Grammar departArrive = new Grammar(cityChooser);
        departArrive.Name = ("Cities Grammar");
        recognizer.LoadGrammarAsync(departArrive);

        // Configure recognizer input.
        recognizer.SetInputToDefaultAudioDevice();

        // Attach a handler for the SpeechRecognized event.
        recognizer.SpeechRecognized +=
          new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);

        // Start asynchronous recognition.
        recognizer.RecognizeAsync();
        Console.WriteLine("Starting asynchronous recognition...");

        // Keep the console window open.
        Console.ReadLine();
      }
    }

    // Handle the SpeechRecognized event.
    static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {
      Console.WriteLine("Speech recognized: " + e.Result.Text);
      Console.WriteLine();
      Console.WriteLine("Semantic results:");
      Console.WriteLine("  The departure city is: " + e.Result.Semantics["departureCity"].Value);
      Console.WriteLine("  The destination city is: " + e.Result.Semantics["arrivalCity"].Value);
    }
  }
}

설명

이 생성자는 포함하는 문법 내의 개체에 대한 SrgsRule 규칙 참조를 만듭니다. 규칙 참조를 만드는 데는 rule 요소를 외부 문법 파일에 다음 생성자 중 하나를 사용 합니다.

추가 정보

적용 대상

SrgsRuleRef(Uri, String)

Source:
SrgsRuleRef.cs
Source:
SrgsRuleRef.cs
Source:
SrgsRuleRef.cs

참조에 대한 외부 문법 파일의 위치와 규칙의 식별자를 지정하는 SrgsRuleRef 클래스의 새 인스턴스를 초기화합니다.

public:
 SrgsRuleRef(Uri ^ uri, System::String ^ rule);
public SrgsRuleRef (Uri uri, string rule);
new System.Speech.Recognition.SrgsGrammar.SrgsRuleRef : Uri * string -> System.Speech.Recognition.SrgsGrammar.SrgsRuleRef
Public Sub New (uri As Uri, rule As String)

매개 변수

uri
Uri

포함하는 문법 이외의 문법 파일 위치입니다.

rule
String

참조할 규칙의 식별자입니다.

예외

uri이(가) null인 경우

rule이(가) null인 경우

rule가 비어 있는 경우

설명

이 생성자에 대 한 규칙 참조를 만듭니다를 rule 외부 문법 파일에는 요소입니다. 규칙 참조를 만드는 데는 SrgsRule 같은 문법 내 개체, 다음과 같은 생성자 중 하나를 사용 합니다.

추가 정보

적용 대상

SrgsRuleRef(SrgsRule, String, String)

Source:
SrgsRuleRef.cs
Source:
SrgsRuleRef.cs
Source:
SrgsRuleRef.cs

참조에 대한 규칙, 의미 사전의 문자열 별칭 및 초기화 매개 변수를 지정하는 SrgsRuleRef 클래스의 새 인스턴스를 초기화합니다.

public:
 SrgsRuleRef(System::Speech::Recognition::SrgsGrammar::SrgsRule ^ rule, System::String ^ semanticKey, System::String ^ parameters);
public SrgsRuleRef (System.Speech.Recognition.SrgsGrammar.SrgsRule rule, string semanticKey, string parameters);
new System.Speech.Recognition.SrgsGrammar.SrgsRuleRef : System.Speech.Recognition.SrgsGrammar.SrgsRule * string * string -> System.Speech.Recognition.SrgsGrammar.SrgsRuleRef
Public Sub New (rule As SrgsRule, semanticKey As String, parameters As String)

매개 변수

rule
SrgsRule

참조할 개체입니다.

semanticKey
String

의미 키입니다.

parameters
String

SrgsRuleRef 개체에 대한 초기화 매개 변수입니다.

설명

이 생성자는 포함하는 문법 내의 개체에 대한 SrgsRule 규칙 참조를 만듭니다. 규칙 참조를 만드는 데는 rule 요소를 외부 문법 파일에 다음 생성자 중 하나를 사용 합니다.

추가 정보

적용 대상

SrgsRuleRef(Uri, String, String)

Source:
SrgsRuleRef.cs
Source:
SrgsRuleRef.cs
Source:
SrgsRuleRef.cs

외부 문법 파일의 위치, 규칙의 식별자 및 의미 사전의 문자열 별칭을 지정하는 SrgsRuleRef 클래스의 새 인스턴스를 초기화합니다.

public:
 SrgsRuleRef(Uri ^ uri, System::String ^ rule, System::String ^ semanticKey);
public SrgsRuleRef (Uri uri, string rule, string semanticKey);
new System.Speech.Recognition.SrgsGrammar.SrgsRuleRef : Uri * string * string -> System.Speech.Recognition.SrgsGrammar.SrgsRuleRef
Public Sub New (uri As Uri, rule As String, semanticKey As String)

매개 변수

uri
Uri

포함하는 문법 이외의 문법 파일 위치입니다.

rule
String

참조할 규칙의 식별자입니다.

semanticKey
String

의미 사전에 대한 별칭 문자열

예외

uri이(가) null인 경우

semanticKey이(가) null인 경우

semanticKey가 비어 있는 경우

설명

이 생성자에 대 한 규칙 참조를 만듭니다를 rule 외부 문법 파일에는 요소입니다. 규칙 참조를 만드는 데는 SrgsRule 같은 문법 내 개체, 다음과 같은 생성자 중 하나를 사용 합니다.

추가 정보

적용 대상

SrgsRuleRef(Uri, String, String, String)

Source:
SrgsRuleRef.cs
Source:
SrgsRuleRef.cs
Source:
SrgsRuleRef.cs

외부 문법 파일의 위치, 규칙의 식별자, 의미 사전의 문자열 별칭 및 초기화 매개 변수를 지정하는 SrgsRuleRef 클래스의 새 인스턴스를 초기화합니다.

public:
 SrgsRuleRef(Uri ^ uri, System::String ^ rule, System::String ^ semanticKey, System::String ^ parameters);
public SrgsRuleRef (Uri uri, string rule, string semanticKey, string parameters);
new System.Speech.Recognition.SrgsGrammar.SrgsRuleRef : Uri * string * string * string -> System.Speech.Recognition.SrgsGrammar.SrgsRuleRef
Public Sub New (uri As Uri, rule As String, semanticKey As String, parameters As String)

매개 변수

uri
Uri

포함하는 문법 이외의 문법 파일 위치입니다.

rule
String

참조할 규칙의 식별자입니다.

semanticKey
String

의미 키입니다.

parameters
String

SrgsRuleRef 개체에 대한 초기화 매개 변수입니다.

설명

이 생성자에 대 한 규칙 참조를 만듭니다를 rule 외부 문법 파일에는 요소입니다. 규칙 참조를 만드는 데는 SrgsRule 같은 문법 내 개체, 다음과 같은 생성자 중 하나를 사용 합니다.

추가 정보

적용 대상