SemanticResultValue 생성자

정의

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

오버로드

SemanticResultValue(Object)

SemanticResultValue 클래스의 새 인스턴스를 초기화하고 의미 값을 지정합니다.

SemanticResultValue(GrammarBuilder, Object)

SemanticResultValue 클래스의 새 인스턴스를 초기화하고 GrammarBuilder 개체를 사용하여 의미 값을 연결합니다.

SemanticResultValue(String, Object)

SemanticResultValue 클래스의 새 인스턴스를 초기화하고 String 개체를 사용하여 의미 값을 연결합니다.

설명

합니다 SemanticResultValue 생성자 지정을 지원를 Object 을 기본 데이터 형식 인스턴스와 bool, intfloat, 또는 string합니다.

생성자를 만들 수는 SemanticResultValue 두 상황 중 인스턴스:

  • 합니다 SemanticResultValue 사용 하는 경우 인스턴스 문법 요소를 사용 하 여 명시적으로 연결 되어야 합니다는 GrammarBuilder 생성 하는 Grammar합니다.

  • 합니다 SemanticResultValue 이미 연결 된 문자열 값 구 또는 GrammarBuilder 개체입니다.

SemanticResultValue(Object)

SemanticResultValue 클래스의 새 인스턴스를 초기화하고 의미 값을 지정합니다.

public:
 SemanticResultValue(System::Object ^ value);
public SemanticResultValue (object value);
new System.Speech.Recognition.SemanticResultValue : obj -> System.Speech.Recognition.SemanticResultValue
Public Sub New (value As Object)

매개 변수

value
Object

SemanticResultValue에 의해 관리된 값입니다. 형식 bool, int, float 또는 string이어야 합니다.

예제

다음 예제에서는 반환 된 Grammar 명령 집합/변경/Alter 전경/배경... "를 인식 하는 [색 목록] "입니다. SemanticResultValueSemanticResultKey 인스턴스 (함께에서 ChoicesGrammarBuilder 개체) 인식을 구문 분석할 수 있는 의미 체계를 정의 하는 데 사용 됩니다. 구문 분석 된 의미 체계는 색 요청한 및 포그라운드 또는 백그라운드 인지 수정할 결정 됩니다.

private Grammar FgBgColorGrammar()   
{  
  Grammar grammar = null;  

  // Allow the command to begin with set, alter, change.  
  Choices introChoices = new Choices();  
  foreach (string introString in new string[] { "Change", "Set", "Alter" })   
  {  
    GrammarBuilder introGB = new GrammarBuilder(introString);  
    introChoices.Add(  
                  new SemanticResultValue(introGB,  
                  String.Format("Command: {0}", introString)));  
  }           

  GrammarBuilder cmdIntro = new GrammarBuilder(introChoices);  

  // Define the arguments for the command to select foreground or background   
  // and to change their color as semantic values.  
  Choices fgOrbgChoice = new Choices();  
  GrammarBuilder backgroundGB=new GrammarBuilder("background");  
  backgroundGB.Append(new SemanticResultValue(true));  
  fgOrbgChoice.Add(backgroundGB);  
  fgOrbgChoice.Add((GrammarBuilder)new SemanticResultValue("foreground", false));  
  SemanticResultKey fgOrbgChoiceKey = new SemanticResultKey("BgOrFgBool", fgOrbgChoice);  
  Choices colorChoice = new Choices();  
  foreach (string colorName in System.Enum.GetNames(typeof(KnownColor)))   
  {  

    // Use implicit conversion of SemanticResultValue to GrammarBuilder.      
    colorChoice.Add(  
                 (GrammarBuilder) (new SemanticResultValue(colorName, (Color.FromName(colorName)).Name)));  
  }  

  // Create a GrammarBuilder for CmdArgs to be appended to CmdIntro using  
  // semantic keys.  
  GrammarBuilder cmdArgs = new GrammarBuilder();  
  cmdArgs.Append(new SemanticResultKey("BgOrFgBool", fgOrbgChoice));  
  cmdArgs.AppendWildcard();  
  cmdArgs.Append(new SemanticResultKey("colorStringList", colorChoice));  

  GrammarBuilder cmds =   
      GrammarBuilder.Add(  
        cmdIntro,   
        new GrammarBuilder(new SemanticResultKey("Cmd Args", cmdArgs)));  
  grammar = new Grammar(cmds);  
  grammar.Name = "Tree [Set,change,alter] [foreground,background] * color";  
  return grammar;  
}  

설명

SemanticResultValue 이 반환한 생성자 특정 문법 요소와 연결 되어 있지 않습니다. 인스턴스를 사용 하 여 명시적 연결을 만들 수 있어야 합니다 SemanticResultValue 와 함께에서 GrammarBuilder입니다.

예를 들어 경우 아래 코드 조각에에서는 Grammar 이 사용 하 여 생성 GrammarBuilder 인스턴스 값을 "백그라운드" 단어를 인식 true 인식 된 구와 의미 체계에 설정 됩니다.

GrammarBuilder backgroundGB=new GrammarBuilder("background");  
backgroundGB.Append(new SemanticResultValue(true));  

적용 대상

SemanticResultValue(GrammarBuilder, Object)

SemanticResultValue 클래스의 새 인스턴스를 초기화하고 GrammarBuilder 개체를 사용하여 의미 값을 연결합니다.

public:
 SemanticResultValue(System::Speech::Recognition::GrammarBuilder ^ builder, System::Object ^ value);
public SemanticResultValue (System.Speech.Recognition.GrammarBuilder builder, object value);
new System.Speech.Recognition.SemanticResultValue : System.Speech.Recognition.GrammarBuilder * obj -> System.Speech.Recognition.SemanticResultValue
Public Sub New (builder As GrammarBuilder, value As Object)

매개 변수

builder
GrammarBuilder

인식에 사용할 수 있는 문법 구성 요소

value
Object

SemanticResultValue에 의해 관리된 값입니다. 형식 bool, int, float 또는 string이어야 합니다.

예제

다음 예제에서는 반환 된 Grammar 명령 집합/변경/Alter 전경/배경... "를 인식 하는 [색 목록] "입니다. SemanticResultValueSemanticResultKey 인스턴스 (함께에서 ChoicesGrammarBuilder 개체) 인식을 구문 분석할 수 있는 의미 체계를 정의 하는 데 사용 됩니다. 구문 분석 된 의미 체계는 색 요청한 및 포그라운드 또는 백그라운드 인지 수정할 결정 됩니다.

private Grammar FgBgColorGrammar()   
{  
  Grammar grammar = null;  

  // Allow the command to begin with set, alter, change.  
  Choices introChoices = new Choices();  
  foreach (string introString in new string[] { "Change", "Set", "Alter" })   
  {  
    GrammarBuilder introGB = new GrammarBuilder(introString);  
    introChoices.Add(  
                  new SemanticResultValue(introGB,  
                  String.Format("Command: {0}", introString)));  
  }           
  GrammarBuilder cmdIntro = new GrammarBuilder(introChoices);  

  // Define the arguments for the command to select foreground or background   
  // and to change their color as semantic values.  
  Choices fgOrbgChoice = new Choices();  
  GrammarBuilder backgroundGB=new GrammarBuilder("background");  
  backgroundGB.Append(new SemanticResultValue(true));  
  fgOrbgChoice.Add(backgroundGB);  
  fgOrbgChoice.Add((GrammarBuilder)new SemanticResultValue("foreground", false));  
  SemanticResultKey fgOrbgChoiceKey = new SemanticResultKey("BgOrFgBool", fgOrbgChoice);  
  Choices colorChoice = new Choices();  
  foreach (string colorName in System.Enum.GetNames(typeof(KnownColor)))   
  {  

    // Use implicit conversion of SemanticResultValue to GrammarBuilder.      
    colorChoice.Add(  
              (GrammarBuilder) (new SemanticResultValue(colorName, (Color.FromName(colorName)).Name)));  
    }  

  // Create a GrammarBuilder for CmdArgs to be appended to CmdIntro using  
  // semantic keys.  
  GrammarBuilder cmdArgs = new GrammarBuilder();  
  cmdArgs.Append(new SemanticResultKey("BgOrFgBool", fgOrbgChoice));  
  cmdArgs.AppendWildcard();  
  cmdArgs.Append(new SemanticResultKey("colorStringList", colorChoice));  

  GrammarBuilder cmds =   
      GrammarBuilder.Add(  
                      cmdIntro,  
                      new GrammarBuilder(new SemanticResultKey("Cmd Args", cmdArgs)));  
  grammar = new Grammar(cmds);  
  grammar.Name = "Tree [Set,change,alter] [foreground,background] * color";  
  return grammar;  
}  

설명

문법 요소를 지정 하면 GrammarBuilder 인식 논리는 value 인식할 수 있는 출력의 의미 체계에 설정 됩니다.

경우 아래 코드 조각에서 인식 논리를 사용 하 여 생성 합니다 GrammarBuilder 인스턴스 (myGb) 사용 합니다 Choices 개체 (myChoice) 식별 값을 입력 합니다 true 인식할 수 있는 의미 체계에 추가 됩니다.

myGb.Append(new SemanticResultValue(myChoice, true);  

GrammarBuilder 에 대 한 암시적 변환을 지 원하는 Choices, SemanticResultValue, 및 SemanticResultKey,이 생성자는 해당 개체도 사용할 수 있습니다.

적용 대상

SemanticResultValue(String, Object)

SemanticResultValue 클래스의 새 인스턴스를 초기화하고 String 개체를 사용하여 의미 값을 연결합니다.

public:
 SemanticResultValue(System::String ^ phrase, System::Object ^ value);
public SemanticResultValue (string phrase, object value);
new System.Speech.Recognition.SemanticResultValue : string * obj -> System.Speech.Recognition.SemanticResultValue
Public Sub New (phrase As String, value As Object)

매개 변수

phrase
String

인식에 사용할 수 있는 구

value
Object

SemanticResultValue에 의해 관리된 값입니다. 형식 bool, int, float 또는 string이어야 합니다.

예제

다음 예제에서는 반환 된 Grammar 명령 집합/변경/Alter 전경/배경... "를 인식 하는 [색 목록] "입니다. SemanticResultValueSemanticResultKey 인스턴스 (함께에서 ChoicesGrammarBuilder 개체) 인식을 구문 분석할 수 있는 의미 체계를 정의 하는 데 사용 됩니다. 구문 분석 된 의미 체계는 색 요청한 및 포그라운드 또는 백그라운드 인지 수정할 결정 됩니다.

private Grammar FgBgColorGrammar()   
{  
  Grammar grammar = null;  

  // Allow command to begin with set, alter, change.  
  Choices introChoices = new Choices();  
  foreach (string introString in new string[] { "Change", "Set", "Alter" })   
  {  
    GrammarBuilder introGB = new GrammarBuilder(introString);  
    introChoices.Add(  
                  new SemanticResultValue(introGB,  
                  String.Format("Command: {0}", introString)));  
  }  

  GrammarBuilder cmdIntro = new GrammarBuilder(introChoices);  

  // Define the arguments for the command to select foreground or background   
  // and to change their color as semantic values.  
  Choices fgOrbgChoice = new Choices();  
  GrammarBuilder backgroundGB=new GrammarBuilder("background");  
  backgroundGB.Append(new SemanticResultValue(true));  
  fgOrbgChoice.Add(backgroundGB);  
  fgOrbgChoice.Add((GrammarBuilder)new SemanticResultValue("foreground", false));  
  SemanticResultKey fgOrbgChoiceKey = new SemanticResultKey("BgOrFgBool", fgOrbgChoice);  
  Choices colorChoice = new Choices();  
  foreach (string colorName in System.Enum.GetNames(typeof(KnownColor)))   
  {  

    // Use implicit conversion of SemanticResultValue to GrammarBuilder.      
    colorChoice.Add(  
          (GrammarBuilder) (new SemanticResultValue(colorName, (Color.FromName(colorName)).Name)));  
  }  

  // Create a GrammarBuilder for CmdArgs to be appended to CmdIntro using  
  // semantic keys.  
  GrammarBuilder cmdArgs = new GrammarBuilder();  
  cmdArgs.Append(new SemanticResultKey("BgOrFgBool", fgOrbgChoice));  
  cmdArgs.AppendWildcard();  
  cmdArgs.Append(new SemanticResultKey("colorStringList", colorChoice));  

  GrammarBuilder cmds =   
      GrammarBuilder.Add(cmdIntro,  
                         new GrammarBuilder(new SemanticResultKey("Cmd Args", cmdArgs)));  
  grammar = new Grammar(cmds);  
  grammar.Name = "Tree [Set,change,alter] [foreground,background] * color";  
  return grammar;  
}  

설명

문자열을 지정 하 여 phrase 인식 논리는 value 인식할 수 있는 출력의 의미 체계에 설정 됩니다.

인식 논리를 사용 하 여 생성 하는 경우 다음 코드 조각에는 GrammarBuilder 인스턴스 (myGb) "담보 대출 내" 문자열을 사용 하 여 식별 값을 입력 합니다 true 인식할 수 있는 의미 체계에 추가 됩니다.

myGb.Append(new SemanticResultValue("my mortgage", true);  

적용 대상