Share via


SrgsSemanticInterpretationTag 클래스

정의

규칙이 일치할 때 실행되는 ECMAScript 가 포함된 태그를 나타냅니다.

public ref class SrgsSemanticInterpretationTag : System::Speech::Recognition::SrgsGrammar::SrgsElement
[System.Serializable]
public class SrgsSemanticInterpretationTag : System.Speech.Recognition.SrgsGrammar.SrgsElement
public class SrgsSemanticInterpretationTag : System.Speech.Recognition.SrgsGrammar.SrgsElement
[<System.Serializable>]
type SrgsSemanticInterpretationTag = class
    inherit SrgsElement
type SrgsSemanticInterpretationTag = class
    inherit SrgsElement
Public Class SrgsSemanticInterpretationTag
Inherits SrgsElement
상속
SrgsSemanticInterpretationTag
특성

예제

다음 예제에서는 항공편에 대 한 도시를 선택 하는 것에 대 한 문법을 만듭니다. 이 예제에서는 사용 SrgsSemanticInterpretationTag 도시의 공항에 대 한 코드는 각 도시를 의미 값을 할당 합니다. 또한이 예제에서는 SrgsSemanticInterpretationTag 수행한 두 참조 중 각각에 대해 별도 의미 체계 키를 할당 하는 SrgsRuleRef 라는 개체 cityRefSrgsRule 라는 개체 cities. 의미 체계 키 출발 도시 또는 항공권 도착 시 인식할 수 있는 도시를 식별합니다. 에 대 한 처리기를 SpeechRecognized 이벤트 키를 사용 하 여 인식 결과에서 의미 체계를 가져옵니다.

코드 예제에서 "out"를 포함 하는 규칙 변수 참조 SrgsRule합니다. 식을 "제한입니다. LeavingFrom"라는 속성을 가리킵니다 LeavingFrom 이라는 규칙에서 규칙 변수의 bookFlight합니다.

해당 규칙의 규칙 변수를 "rules.flightCities" 식이 참조 IdflightCities, 규칙 참조 대상일 인지 합니다. 예제에서는 식 "제한입니다. LeavingFrom=rules.flightCities;"규칙에서 값을 할당입니다 Id 됩니다 flightCities 라는 속성으로 LeavingFrom 이라는 규칙에서 규칙 변수의 bookFlight합니다. 참조 의미 체계 결과 콘텐츠문법 규칙 이름 참조, 및 문법 규칙 참조를 참조 자세한 내용은 합니다.

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")))  
      {  

        // Create a rule for the cities, assign a semantic value to each city.  
        SrgsRule cities = new SrgsRule("flightCities");  
        SrgsItem chi = new SrgsItem("Chicago");  
        chi.Add(new SrgsSemanticInterpretationTag("out = \"ORD\";"));  
        SrgsItem bos = new SrgsItem("Boston");  
        bos.Add(new SrgsSemanticInterpretationTag("out = \"BOS\";"));  
        SrgsItem mia = new SrgsItem("Miami");  
        mia.Add(new SrgsSemanticInterpretationTag("out = \"MIA\";"));  
        SrgsItem dal = new SrgsItem("Dallas");  
        dal.Add(new SrgsSemanticInterpretationTag("out = \"DFW\";"));  

        SrgsOneOf airports = new SrgsOneOf(chi, bos, mia, dal);  
        cities.Add(airports);  
        cities.Scope = SrgsRuleScope.Private;  

        // Create a rule reference to the rule for cities.  
        SrgsRuleRef cityRef = new SrgsRuleRef(cities);  

        // Create the root rule for the grammar.  
        SrgsRule bookFlight = new SrgsRule("flightBooker");  
        bookFlight.Add(new SrgsItem("I want to fly from"));  
        bookFlight.Add(cityRef);  
        bookFlight.Add(new SrgsSemanticInterpretationTag("out.LeavingFrom=rules.flightCities;"));  
        bookFlight.Add(new SrgsItem("to"));  
        bookFlight.Add(cityRef);  
        bookFlight.Add(new SrgsSemanticInterpretationTag("out.GoingTo=rules.flightCities;"));  
        bookFlight.Scope = SrgsRuleScope.Public;  

        // Initialize the SrgsDocument, set the root rule, add rules to the collection.  
        SrgsDocument itinerary = new SrgsDocument(bookFlight);  
        itinerary.Rules.Add(cities);  

        // Create a Grammar object and load it to the recognizer.  
        Grammar g = new Grammar(itinerary);  
        g.Name = ("City Chooser");  
        recognizer.LoadGrammarAsync(g);  

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

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

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

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

    // Write to the console the text and the semantics from the recognition result.  
    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["LeavingFrom"].Value);  
      Console.WriteLine("  The arrival city is: " + e.Result.Semantics["GoingTo"].Value);  
    }  
  }  
}  

다음은 위의 예제에서 코드로 생성 된 문법의 XML 형식입니다.

<?xml version="1.0" encoding="utf-8"?>  
<grammar xml:lang="en-US" root="flightBooker" tag-format="semantics/1.0"   
version="1.0" xmlns="http://www.w3.org/2001/06/grammar">  

  <rule id="flightBooker" scope="public">  
    <item> I want to fly from </item>  
    <ruleref uri="#flightCities" />   
    <tag> out.LeavingFrom=rules.flightCities; </tag>  
    <item> to </item>  
    <ruleref uri="#flightCities" />   
    <tag> out.GoingTo=rules.flightCities; </tag>  
  </rule>  

  <rule id="flightCities" scope="private">  
    <one-of>  
      <item> Chicago <tag> out="ORD"; </tag></item>  
      <item> Boston <tag> out="BOS"; </tag></item>  
      <item> Miami <tag> out="MIA"; </tag></item>  
      <item> Dallas <tag> out="DFW"; </tag></item>  
    </one-of>  
  </rule>  

</grammar>  

설명

System.Speech의 기본 의미 체계 형식은 W3C 맞게 음성 인식 (SISR) 버전 1.0에 대 한 의미 해석여기서 형식을 tag 스크립트를 포함 하는 요소는 semantics/1.0합니다. 에 대 한 스크립트를 지정 해야 SrgsSemanticInterpretationTag 이 형식을 사용 하 여 개체입니다. 구문의 semantics/1.0:

  • 포함 하는 규칙 요소 규칙 변수 "out"으로 식별 됩니다.

  • 규칙 변수 규칙 요소를 포함 하는 규칙 요소 외부에 액세스할 수 있는 개체의 이름은 "규칙"으로 식별 됩니다.

  • "Rules.latest()" 하 여 최신 참조 규칙의 utterance 일치 하는 결과 나타낼 수 있습니다.

스크립트를 사용 하지 않고 문법에서 구문을 사용 하 여 의미 값을 연결할 수도 있습니다를 사용 하 여 SrgsNameValueTag 개체.

생성자

SrgsSemanticInterpretationTag()

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

SrgsSemanticInterpretationTag(String)

SrgsSemanticInterpretationTag 클래스의 인스턴스를 만들고 태그의 스크립트 내용을 지정합니다.

속성

Script

해당 태그에 대한 ECMAScript를 가져오거나 설정합니다.

메서드

CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시 생성에 필요한 모든 관련 정보가 들어 있는 개체를 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 현재의 수명 서비스 개체를 검색합니다.

(다음에서 상속됨 MarshalByRefObject)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
InitializeLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.

(다음에서 상속됨 MarshalByRefObject)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
MemberwiseClone(Boolean)

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상