RecognizedPhrase.Semantics 屬性

定義

取得與該片語相關的語意資訊。

public:
 property System::Speech::Recognition::SemanticValue ^ Semantics { System::Speech::Recognition::SemanticValue ^ get(); };
public System.Speech.Recognition.SemanticValue? Semantics { get; }
public System.Speech.Recognition.SemanticValue Semantics { get; }
member this.Semantics : System.Speech.Recognition.SemanticValue
Public ReadOnly Property Semantics As SemanticValue

屬性值

與已知片語相關的語意資訊。

範例

以下範例定義了一種從已知片語取得特定語意資訊的方法。 當此方法回傳時,包含語意鍵的值,若未取得則為 null。 此方法僅檢查頂層鍵。 由於語意資訊包含在值樹中,較低階的鍵必須透過回傳的語意值來存取。

static bool TryGetSemanticValue(
      RecognizedPhrase phrase, string key, out SemanticValue value)
{
  value = null;
  bool found = phrase.Semantics.ContainsKey(key);
  if (found)
  {
    value = phrase.Semantics[key];
  }

  return found;
}

備註

語音辨識文法可以包含語意資訊。 當語音辨識器產生此類文法的識別結果時,根據文法規則及輸入,語意資訊可能會被納入識別結果中。 欲了解更多語意資訊,請參閱 SemanticResultKey and SemanticResultValue 類別。

適用於

另請參閱