Aracılığıyla paylaş


RecognizedWordUnit.Text Özellik

Tanım

Tanınan bir sözcük için normalleştirilmiş metni alır.

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

Özellik Değeri

String

Verilen bir giriş sözcüğü için normalleştirilmiş metin çıkışını içeren dize.

Örnekler

Aşağıdaki örnek, üç biçimden biri içinde dize oluşturan bir yardımcı program yordamını gösterir: sözcük LexicalForm (kullanarak), normalleştirilmiş (kullanarak) ve Text phonetic Pronunciation (kullanarak). Metin çıktısı, nesnedeki ReadOnlyCollection<T> RecognizedWordUnit özelliğinden elde edilen Words nesnelerinden RecognizedPhrase elde edilir.

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

Açıklamalar

Çoğu durumda ve tarafından döndürülen Text LexicalForm değerler aynı olur. Ancak tanıma altyapıları, ses girişinin daha kolay veya aynı metin gösterimlerini geri dönmek için konuşma normalleştirmeyi kullanabilir.

Konuşma normalleştirme, konuşmayı yazarken ifade etmek için özel yapıların veya sembollerin kullanımıdır. Örneğin normalleştirme, "bir dolar ve on altı sent" sözcüklerini çıkış metninde "$1,16" ile değiştirebilir.

Şunlara uygulanır