RecognizedPhrase.Semantics 屬性

定義

取得與已辨識片語相關聯的語意資訊。

public:
 property System::Speech::Recognition::SemanticValue ^ Semantics { System::Speech::Recognition::SemanticValue ^ 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;  
}  

備註

語音辨識文法可以包含語意資訊。 當語音辨識器產生這類文法的辨識結果時,根據文法的規則和辨識器的輸入,語意資訊可能會包含在辨識結果中。 如需語意資訊的詳細資訊,請參閱 瞭解語意結果SemanticResultKeySemanticResultValue 類別。

適用於

另請參閱