SemanticResultValue 생성자

정의

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

오버로드

Name Description
SemanticResultValue(Object)

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

SemanticResultValue(GrammarBuilder, Object)

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

SemanticResultValue(String, Object)

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

설명

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

생성자는 다음 두 가지 상황 중 하나에서 인스턴스를 만들 SemanticResultValue 수 있습니다.

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

  • SemanticResultValue 문자열 값 구 또는 개체와 이미 연결되어 있습니다GrammarBuilder.

SemanticResultValue(Object)

Source:
SemanticResultValue.cs
Source:
SemanticResultValue.cs
Source:
SemanticResultValue.cs
Source:
SemanticResultValue.cs

클래스의 새 인스턴스를 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또는 floatstring.이어야 합니다.

예제

다음 예제 Grammar 에서는 "Set/Change/Alter Foreground/Background ... [색 목록]". SemanticResultValueSemanticResultKey 인스턴스(개체와 Choices 함께GrammarBuilder)는 인식 시 구문 분석할 수 있는 의미 체계를 정의하는 데 사용됩니다. 구문 분석된 의미 체계는 요청된 색과 전경 또는 배경을 수정할지 여부를 결정합니다.

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 이 생성자가 반환한 값은 특정 문법 요소와 연결되지 않습니다. 연결은 인스턴스를 SemanticResultValueGrammarBuilder함께 사용하여 명시적으로 만들어야 합니다.

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

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

적용 대상

SemanticResultValue(GrammarBuilder, Object)

Source:
SemanticResultValue.cs
Source:
SemanticResultValue.cs
Source:
SemanticResultValue.cs
Source:
SemanticResultValue.cs

클래스의 새 인스턴스를 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또는 floatstring.이어야 합니다.

예제

다음 예제 Grammar 에서는 "Set/Change/Alter Foreground/Background ... [색 목록]". SemanticResultValueSemanticResultKey 인스턴스(개체와 Choices 함께GrammarBuilder)는 인식 시 구문 분석할 수 있는 의미 체계를 정의하는 데 사용됩니다. 구문 분석된 의미 체계는 요청된 색과 전경 또는 배경을 수정할지 여부를 결정합니다.

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 생성된 인식 논리가 개체(myGbmyChoice)를 사용하여 Choices 입력을 식별하는 경우 값 true 이 인식된 의미 체계에 추가됩니다.

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

GrammarBuilder 에 대한 ChoicesSemanticResultValue암시적 변환을 지원하므로 SemanticResultKey이 생성자도 이러한 개체를 사용할 수 있습니다.

적용 대상

SemanticResultValue(String, Object)

Source:
SemanticResultValue.cs
Source:
SemanticResultValue.cs
Source:
SemanticResultValue.cs
Source:
SemanticResultValue.cs

클래스의 새 인스턴스를 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또는 floatstring.이어야 합니다.

예제

다음 예제 Grammar 에서는 "Set/Change/Alter Foreground/Background ... [색 목록]". SemanticResultValueSemanticResultKey 인스턴스(개체와 Choices 함께GrammarBuilder)는 인식 시 구문 분석할 수 있는 의미 체계를 정의하는 데 사용됩니다. 구문 분석된 의미 체계는 요청된 색과 전경 또는 배경을 수정할지 여부를 결정합니다.

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 에 사용되는 경우 인식된 출력의 의미 체계에서 설정됩니다.

다음 코드 조각에서 인스턴스(myGb)로 GrammarBuilder 생성된 인식 논리가 "my mortgage" 문자열을 사용하여 입력을 식별하는 경우 값 true 이 인식된 의미 체계에 추가됩니다.

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

적용 대상