GrammarBuilder.DebugShowPhrases 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得顯示 GrammarBuilder 所含文法之內容及結構的字串。
public:
property System::String ^ DebugShowPhrases { System::String ^ get(); };
public string DebugShowPhrases { get; }
member this.DebugShowPhrases : string
Public ReadOnly Property DebugShowPhrases As String
屬性值
GrammarBuilder 的目前內容和結構。
範例
下列範例會建立語音辨識文法,以訂購最多四個配料的披薩。 它會先將 的狀態 GrammarBuilder 寫入主控台,再建立文法。 這個方法會產生下列輸出:
GrammarBuilder status: I would like a [cheese,mushroom,tomato,onion,anchovy,chic ken,pepperoni] and [cheese,mushroom,tomato,onion,anchovy,chicken,pepperoni] pizza
private static Grammar CreatePizzaGrammar()
{
// Create a Choices object with alternatives for toppings.
Choices toppings = new Choices(new string[] {
"cheese", "mushroom", "tomato", "onion",
"anchovy", "chicken", "pepperoni"});
// Create a GrammarBuilder and append the Choices object.
GrammarBuilder andToppings = new GrammarBuilder("and", 0, 1);
andToppings.Append(toppings);
// Construct the phrase.
GrammarBuilder gb = new GrammarBuilder("I would like a", 0, 1);
gb.Append(toppings);
gb.Append(new GrammarBuilder(andToppings, 0, 3));
gb.Append("pizza");
// Write the contents and structure of the GrammarBuilder to the console.
Console.WriteLine("Grammar content and structure: {0}", gb.DebugShowPhrases);
// Create the Grammar from the GrammarBuilder.
Grammar grammar = new Grammar(gb);
grammar.Name = "Pizza Order";
return grammar;
}