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 を返します。

次の例は、字句 (を使用)、正規化 (を使用Text)、ふりがな (を使用) LexicalFormの 3 つの形式のいずれかでテキストを生成するユーティリティ ルーチンをPronunciation示しています。 テキスト出力は、 オブジェクトの RecognizedWordUnit から取得ReadOnlyCollection<T>されます。これは、 オブジェクトの WordsRecognizedPhrase プロパティから取得されます。

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;  
}  

注釈

ほとんどの場合、 と LexicalForm によってText返される値は同じです。 ただし、認識エンジンでは、音声の正規化を使用して、オーディオ入力のよりわかりやすいテキスト表現または口語テキスト表現を返すことができます。

音声正規化は、特別なコンストラクトまたは記号を使用して、書き込みで音声を表現します。 たとえば、正規化では、読み上げられた単語 "a dollar and 16 cents" を出力テキストの "$1.16" に置き換えることができます。

適用対象

こちらもご覧ください