RecognizedWordUnit.LexicalForm 屬性

定義

取得所辨識之單字的未標準化文字。

public:
 property System::String ^ LexicalForm { System::String ^ get(); };
public string LexicalForm { get; }
member this.LexicalForm : string
Public ReadOnly Property LexicalForm As String

屬性值

傳回 String,包含所辨識之單字的文字,不含任何正常化。

範例

下列範例顯示公用程式常式,其會以下列三種格式之一產生文字:使用) 的語彙 (、使用 LexicalFormText) 正規化 (,以及使用) 的 Pronunciation 注音 (。 文字輸出是從 物件的 取得 ReadOnlyCollection<T>RecognizedWordUnit ,從 物件的 屬性 RecognizedPhrase 取得 Words

internal enum WordType   
{  
  Text,  
  Normalized = Text,  
  Lexical,  
  Pronunciation  
}  
internal static string stringFromWordArray(  
         ReadOnlyCollection<RecognizedWordUnit> words,   
         WordType type)   
{  
  string text = "";  
  foreach (RecognizedWordUnit word in words)   
  {  
    string wordText = "";  
    if (type == WordType.Text || type == WordType.Normalized)   
    {  
      wordText = word.Text;  
    }   
    else if (type == WordType.Lexical)   
    {  
      wordText = word.LexicalForm;  
    }   
    else if (type == WordType.Pronunciation)   
    {  
      wordText = word.Pronunciation;  
    }   
    else   
    {  
      throw new InvalidEnumArgumentException(  
          String.Format("[0}: is not a valid input", type));  
    }  

    // Use display attribute  
    if ((word.DisplayAttributes & DisplayAttributes.OneTrailingSpace) != 0)   
    {  
      wordText += " ";  
    }  
    if ((word.DisplayAttributes & DisplayAttributes.TwoTrailingSpaces) != 0)  
    {  
      wordText += "  ";  
    }  
    if ((word.DisplayAttributes & DisplayAttributes.ConsumeLeadingSpaces) != 0)   
    {  
      wordText = wordText.TrimStart();  
    }  
    if ((word.DisplayAttributes & DisplayAttributes.ZeroTrailingSpaces) != 0)  
    {  
    wordText = wordText.TrimEnd();  
    }  

    text += wordText;  

  }  
  return text;  
}  

備註

在大部分情況下,和 LexicalFormText 傳回的值都相同。 不過,辨識引擎可能會使用語音正規化來傳回更方便使用者或音訊輸入的定序文字表示。

語音正規化是使用特殊建構或符號來表達書寫中的語音。 例如,正規化可以在輸出文字中以 「$1.16」 取代口說文字 「a dollar and sixteen cents」。

適用於

另請參閱