RecognizedWordUnit.LexicalForm Propiedad

Definición

Obtiene el texto sin normalizar de una palabra reconocida.

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

Valor de propiedad

Devuelve un objeto String que contiene el texto de una palabra reconocida, sin ninguna normalización.

Ejemplos

En el ejemplo siguiente se muestra una rutina de utilidad que genera texto en uno de los tres formatos: léxico (mediante LexicalForm), normalizado (mediante Text) y fonético (mediante Pronunciation). La salida de texto se obtiene de un ReadOnlyCollection<T> objeto de RecognizedWordUnit objetos , que se obtiene de la Words propiedad en el RecognizedPhrase objeto .

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

Comentarios

En la mayoría de los casos, los valores devueltos por Text y LexicalForm son idénticos. Sin embargo, los motores de reconocimiento pueden usar la normalización de voz para devolver representaciones de texto más fáciles de usar o coloquiales de entrada de audio.

La normalización de voz es el uso de construcciones o símbolos especiales para expresar la voz por escrito. Por ejemplo, la normalización puede reemplazar las palabras habladas "un dólar y dieciséis centavos" por "$1,16" en el texto de salida.

Se aplica a

Consulte también