SemanticResultValue 클래스

정의

의미값을 표현하며 선택적으로 스피치 인식 그래머의 콤포넌트와 값을 관련짓는다

public ref class SemanticResultValue
public class SemanticResultValue
type SemanticResultValue = class
Public Class SemanticResultValue
상속
SemanticResultValue

예제

다음 예제에서는 반환 된 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 하 고 SemanticResultKey 개체와 함께에서 GrammarBuilderChoices, 의미 체계 구조를 디자인 하는 가장 쉬운 방법은 Grammar입니다. 인스턴스를 가져와서 구문을 의미 체계 정보에 액세스할 SemanticValue을 통해 합니다 Semantics 속성을 RecognizedPhrase입니다.

참고

관리 하는 값 SemanticResultValue 개체는 정의한 Object 인스턴스가 해당 생성자에 전달 합니다. 이 기본 유형은 Object 있어야 bool, int, float, 또는 string. 다른 형식 생성 되지 것입니다는 Grammar 인스턴스는 SemanticResultValue합니다.

사용 하는 일반적인를 SemanticResultValue 의 인식할 수 있는 구성 요소를 사용 하 여 인스턴스를 연결 하는 인스턴스를 Grammar, 구, 규칙, 같은 또는 Choices 개체입니다. 연결된 된 구성 요소를 인식 작업의 일부로 사용 되는 경우는 SemanticResultValue 반환 된 구의 의미 체계에서 값을 정의 하는 데 사용 됩니다.

두 가지가 있습니다 기본 연결을 SemanticResultValue 문법 요소를 만드는 데 사용 된 생성자에 따라 사용 하 여 인스턴스를 SemanticResultValue입니다.

  • 만 값 (인스턴스의 지정 된 Object) 생성 하는 데 사용 되는 SemanticResultValue 개체를 SemanticResultValue 외에, 앞에 오는 문법 구성 요소와 연결 된를 GrammarBuilder 개체.

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

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

    자세한 내용은 SemanticResultValue(Object)의 설명을 참조하세요.

  • 문자열 값 구 또는 특정 GrammarBuilder 인스턴스가 사용 되는 함께 Object 지정 하는 SemanticResultValue 값을 값의 문자열 값 구문으로 자동으로 연결 되었는지 또는 GrammarBuilder 인스턴스. 경우는 구 또는 GrammarBuilder 인식된 된 구와의 의미 체계에 할당할 값, 개체 인식 프로세스에 사용 됩니다.

    다음 예제에서는이 보여 줍니다 이며를 명시적으로 호출 하는 이전 예제와 기능적 AppendSemanticResultValue(Object)입니다. 인식 논리 단어 "백그라운드" 값을 사용 하는 경우 true 인식할 수 있는 의미 체계에 추가 됩니다.

    fgOrbgChoice.Add((GrammarBuilder)new SemanticResultValue("background", true));
    

    자세한 내용은 참조에 대 한 설명을 SemanticResultValue(GrammarBuilder, Object)SemanticResultValue(String, Object)입니다.

사용할를 Grammar 인식에서 모든 SemanticResultValue 인스턴스 중 하나를 사용 하 여 연결 해야 합니다 SemanticValue 에서 사용 되는 개체 Grammar. 사용 하 여 의미 체계 키를 연결 하 여 이렇게는 SemanticResultValue합니다.

의미 체계 키를 명시적으로 연결할 수는 SemanticResultValue를 사용 하 여를 SemanticResultKey 개체입니다. SemanticResultValue 인스턴스 키를 명시적으로 연결 된 기본 루트 키에 연결 된 SemanticValue합니다.

후는 SemanticResultValue 설정 하는 데 사용 된 합니다 Value기본 루트 키를 사용 하 여 또는 특정 태그가 지정 됩니다 여부와 관계 없이 SemanticResultKey, 해당 값을 수정 하지 않아야 또는 인식 작업 하는 동안 예외가 발생 합니다.

다음 예제에서는 설정 하 고 루트를 수정 하기 때문에 예외가 발생 되는지 ValueGrammar합니다.

GrammarBuilder gb=new GrammarBuilder();
gb.Append(new SemanticResultValue("One"));
gb.Append(new SemanticResultValue("Two"));

반면에 다음 예제 코드에서는 허용 됩니다. 여러 인스턴스를 정의 하지만 SemanticResultValue에 포함 된를 Choices 개체 및 키의 값을 설정 하려면 사용한 적이 하나만 bgOrfgText합니다.

Choices fgOrbgChoice = new Choices();
fgOrbgChoice.Add((GrammarBuilder)new SemanticResultValue("background"));
fgOrbgChoice.Add((GrammarBuilder)new SemanticResultValue("foreground"));
SemanticResultKey fgOrbgChoiceKey = new SemanticResultKey("BgOrFgText", fgOrbgChoice);

생성자

SemanticResultValue(GrammarBuilder, Object)

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

SemanticResultValue(Object)

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

SemanticResultValue(String, Object)

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

메서드

Equals(Object)

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

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

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

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

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

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

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

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

현재 GrammarBuilder 인스턴스에서 생성된 SemanticResultValue의 인스턴스를 반환합니다.

ToString()

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

(다음에서 상속됨 Object)

적용 대상

추가 정보