Share via


RecognizedWordUnit.Text Propriété

Définition

Obtient le texte normalisé d'un mot reconnu.

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

Valeur de propriété

Chaîne qui contient la sortie de texte normalisée pour un mot entré donné.

Exemples

L’exemple suivant montre une routine utilitaire qui génère une chaîne dans l’un des trois formats suivants : lexical (à l’aide LexicalFormde ), normalisé (à l’aide Textde ) et phonétique (à l’aide Pronunciationde ). La sortie de texte est obtenue à partir d’un ReadOnlyCollection<T> d’objets RecognizedWordUnit , qui est obtenu à partir de la Words propriété sur l’objet RecognizedPhrase .

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

Remarques

Dans la plupart des cas, les valeurs retournées par Text et LexicalForm sont identiques. Toutefois, les moteurs de reconnaissance peuvent utiliser la normalisation vocale pour retourner des représentations textuelles plus conviviales ou familières de l’entrée audio.

La normalisation vocale est l’utilisation de constructions ou de symboles spéciaux pour exprimer la parole par écrit. Par exemple, la normalisation peut remplacer les mots prononcés « un dollar et seize cents » par « 1,16 $ » dans le texte de sortie.

S’applique à