Aracılığıyla paylaş


GrammarBuilder.Append Yöntem

Tanım

Dil bilgisi öğesini geçerli dil bilgisi öğelerinin dizisine ekler.

Aşırı Yüklemeler

Append(String, Int32, Int32)

Geçerli dil bilgisi öğeleri dizisine yinelenen bir tümcecik ekler.

Append(GrammarBuilder, Int32, Int32)

Yinelenen bir dil bilgisi öğesini geçerli dil bilgisi öğelerinin dizisine ekler.

Append(String)

Geçerli dil bilgisi öğeleri dizisine bir tümcecik ekler.

Append(String, SubsetMatchingMode)

Bir tümceciği alt kümesi için bir öğeyi geçerli dil bilgisi öğelerinin dizisine ekler.

Append(SemanticResultKey)

Geçerli dil bilgisi öğeleri dizisine semantik bir anahtar ekler.

Append(SemanticResultValue)

Geçerli dil bilgisi öğelerinin dizisine semantik bir değer ekler.

Append(GrammarBuilder)

Dil bilgisi öğesini geçerli dil bilgisi öğelerinin dizisine ekler.

Append(Choices)

Geçerli dil bilgisi öğeleri dizisine bir dizi alternatif ekler.

Açıklamalar

Dil bilgisi öğelerini var olan GrammarBuilderbir öğesine eklemek için bu yöntemleri kullanın. Dil bilgisi öğeleri oluştururken, bunları mevcut oluşturucuya ekleyerek konuşma tanıma dil bilgisi kısıtlamalarını aşamalı olarak geliştirebilirsiniz. Her öğe geçerli öğe dizisinin sonuna eklenir.

Bu yöntemin , , String, ChoicesSemanticResultKeyve SemanticResultValue nesnelerini eklemeye GrammarBuilderyönelik aşırı yüklemeleri vardır.

Önemli

Konuşma tanıyıcı, aynı anahtar adına sahip yinelenen semantik öğeler veya aynı semantik öğenin değerini tekrar tekrar değiştirebilecek birden çok semantik öğe içeren bir konuşma tanıma dil bilgisi kullanırken özel durum oluşturabilir.

Konuşma tanıma dil bilgisi oluşturma ve kullanma hakkında daha fazla bilgi için bkz. Konuşma Tanıma.

Append(String, Int32, Int32)

Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs

Geçerli dil bilgisi öğeleri dizisine yinelenen bir tümcecik ekler.

public:
 void Append(System::String ^ phrase, int minRepeat, int maxRepeat);
public void Append (string phrase, int minRepeat, int maxRepeat);
member this.Append : string * int * int -> unit
Public Sub Append (phrase As String, minRepeat As Integer, maxRepeat As Integer)

Parametreler

phrase
String

Eklenecek yinelenen sözcük dizisi.

minRepeat
Int32

Eşleşme oluşturmak için giriş eşleştirmesinin phrase en az kaç kez gerçekleşmesi gerektiği.

maxRepeat
Int32

Bir eşleşme oluşturmak için giriş eşleştirmesinin phrase en fazla kaç kez gerçekleşebileceği.

Örnekler

Aşağıdaki örnek, "İş yerinde James'i ara" ve "Cep telefonunda Anne'yi ara" gibi ifadeler için "telefon" sözcüğünün isteğe bağlı olduğu bir konuşma tanıma dil bilgisi oluşturur. GrammarBuilder ve Choices nesneleri dil bilgisini oluşturmak için kullanılır. Örnekte yönteminin Append kullanımı vurgulanır.

public static Grammar CreatePhonePhrase()
{
  // Create alternatives for person names, locations, devices, and pronouns.
  Choices personChoice = new Choices(new string[] {"Anne", "James", "Mary", "Sam"});
  Choices locationChoice = new Choices(new string[] {"home", "work"});
  Choices deviceChoice = new Choices(new string[] {"home", "work", "cell"});
  Choices pronounChoice = new Choices(new string[] {"his", "her"});

  // Create a phrase for the receiving device, which optionally contains the word "phone".
  GrammarBuilder devicePhrase = new GrammarBuilder(pronounChoice);
  devicePhrase.Append(deviceChoice);
  devicePhrase.Append("phone", 0, 1);

  // Create alternatives for phrases specifying a device or a location.
  GrammarBuilder atLocation = new GrammarBuilder("at");
  atLocation.Append(locationChoice);

  GrammarBuilder onDevice = new GrammarBuilder("on");
  onDevice.Append(devicePhrase);

  Choices howChoice = new Choices(new GrammarBuilder[] {atLocation, onDevice});

  // Build the final phrase.
  GrammarBuilder callWho = new GrammarBuilder("Call");
  callWho.Append(personChoice);
  callWho.Append(howChoice);

  // Create the Grammar object.
  Grammar callGrammar = new Grammar(callWho);
  callGrammar.Name = "Call Grammar";

  return callGrammar;
}

Açıklamalar

değeri minRepeat 0'dan büyük veya buna eşit ve değerinden maxRepeatküçük veya eşit olmalıdır.

Ayrıca bkz.

Şunlara uygulanır

Append(GrammarBuilder, Int32, Int32)

Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs

Yinelenen bir dil bilgisi öğesini geçerli dil bilgisi öğelerinin dizisine ekler.

public:
 void Append(System::Speech::Recognition::GrammarBuilder ^ builder, int minRepeat, int maxRepeat);
public void Append (System.Speech.Recognition.GrammarBuilder builder, int minRepeat, int maxRepeat);
member this.Append : System.Speech.Recognition.GrammarBuilder * int * int -> unit
Public Sub Append (builder As GrammarBuilder, minRepeat As Integer, maxRepeat As Integer)

Parametreler

builder
GrammarBuilder

Eklenecek yinelenen dil bilgisi öğesi.

minRepeat
Int32

Tarafından tanımlanan builder öğeyle eşleşen girişin eşleşme oluşturması gereken en az sayı.

maxRepeat
Int32

tarafından tanımlanan builder öğeyle eşleşen girişin en fazla kaç kez eşleşme oluşturabileceği.

Örnekler

Aşağıdaki örnek, "İş yerinde James'i ara" ve "Cep telefonunda Anne'yi ara" gibi ifadeler için "telefon" sözcüğünün isteğe bağlı olduğu bir konuşma tanıma dil bilgisi oluşturur. GrammarBuilder ve Choices nesneleri dil bilgisini oluşturmak için kullanılır. Örnekte yönteminin Append kullanımı vurgulanır.

public static Grammar CreatePhonePhrase()
{
  // Create alternatives for person names, locations, devices, and pronouns.
  Choices personChoice = new Choices(new string[] {"Anne", "James", "Mary", "Sam"});
  Choices locationChoice = new Choices(new string[] {"home", "work"});
  Choices deviceChoice = new Choices(new string[] {"home", "work", "cell"});
  Choices pronounChoice = new Choices(new string[] {"his", "her"});

  // Create a phrase for the receiving device, which optionally contains the word "phone".
  GrammarBuilder devicePhrase = new GrammarBuilder(pronounChoice);
  devicePhrase.Append(deviceChoice);
  devicePhrase.Append("phone", 0, 1);

  // Create alternatives for phrases specifying a device or a location.
  GrammarBuilder atLocation = new GrammarBuilder("at");
  atLocation.Append(locationChoice);

  GrammarBuilder onDevice = new GrammarBuilder("on");
  onDevice.Append(devicePhrase);

  Choices howChoice = new Choices(new GrammarBuilder[] {atLocation, onDevice});

  // Build the final phrase.
  GrammarBuilder callWho = new GrammarBuilder("Call");
  callWho.Append(personChoice);
  callWho.Append(howChoice);

  // Create the Grammar object.
  Grammar callGrammar = new Grammar(callWho);
  callGrammar.Name = "Call Grammar";

  return callGrammar;
}

Açıklamalar

değeri minRepeat 0'dan büyük veya buna eşit ve değerinden maxRepeatküçük veya eşit olmalıdır.

Önemli

Veya içeren SemanticResultValue nesneleri veya SemanticResultKey örneklerini bir GrammarBuilder nesneye eklerkenGrammarBuilder, aynı anahtar adına sahip yinelenen semantik öğeler veya bir SemanticValue nesnenin özelliğini tekrar tekrar değiştirebilecek Value birden çok semantik öğe oluşturmaktan kaçının. Konuşma tanıyıcısı bu durumlarla karşılaşırsa bir özel durum oluşturabilir.

Ayrıca bkz.

Şunlara uygulanır

Append(String)

Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs

Geçerli dil bilgisi öğeleri dizisine bir tümcecik ekler.

public:
 void Append(System::String ^ phrase);
public void Append (string phrase);
member this.Append : string -> unit
Public Sub Append (phrase As String)

Parametreler

phrase
String

Eklenecek sözcük dizisi.

Açıklamalar

phrase geçerli öğe dizisinin sonuna eklenir.

Ayrıca bkz.

Şunlara uygulanır

Append(String, SubsetMatchingMode)

Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs

Bir tümceciği alt kümesi için bir öğeyi geçerli dil bilgisi öğelerinin dizisine ekler.

public:
 void Append(System::String ^ phrase, System::Speech::Recognition::SubsetMatchingMode subsetMatchingCriteria);
public void Append (string phrase, System.Speech.Recognition.SubsetMatchingMode subsetMatchingCriteria);
member this.Append : string * System.Speech.Recognition.SubsetMatchingMode -> unit
Public Sub Append (phrase As String, subsetMatchingCriteria As SubsetMatchingMode)

Parametreler

phrase
String

Eklenecek sözcük dizisi.

subsetMatchingCriteria
SubsetMatchingMode

Dil bilgisinin tümceciği tanımak için kullandığı eşleştirme modu.

Örnekler

Aşağıdaki örnek, her SubsetMatchingMode değer için bir konuşma tanıma dil bilgisi oluşturur. Örneğin, oluşturulan dil bilgisi OrderedSubset "üç dört beş" ve "bir üç beş" tümceciklerini tanır ve dil bilgisi Subsequence "üç dört beş" tümceciği tanır, ancak "bir üç beş" tümceciği tanımaz.

private Grammar[] CreateSubsetMatchTest()
{
  List<Grammar> grammars = new List<Grammar>(4);

  string phrase = "one two three four five six";
  foreach (SubsetMatchingMode mode in
    Enum.GetValues(typeof(SubsetMatchingMode)))
  {
    GrammarBuilder gb = new GrammarBuilder();
    gb.Append(phrase, mode);

    Grammar grammar = new Grammar(gb);
    grammar.Name = mode.ToString();
    grammars.Add(grammar);
  }

  return grammars.ToArray();
}

Açıklamalar

Alt küme öğesi geçerli öğe dizisinin sonuna eklenir. Dizeleri kullanarak konuşma tanıma dil bilgisi oluşturma hakkında daha fazla bilgi için bkz. GrammarBuilder Dilbilgisi Oluşturmak için Dizeleri Kullanma.

Alt küme eşleştirme modlarının kullanımı hakkında ayrıntılı bilgi için bkz System.Speech.Recognition.SubsetMatchingMode. .

Ayrıca bkz.

Şunlara uygulanır

Append(SemanticResultKey)

Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs

Geçerli dil bilgisi öğeleri dizisine semantik bir anahtar ekler.

public:
 void Append(System::Speech::Recognition::SemanticResultKey ^ key);
public void Append (System.Speech.Recognition.SemanticResultKey key);
member this.Append : System.Speech.Recognition.SemanticResultKey -> unit
Public Sub Append (key As SemanticResultKey)

Parametreler

key
SemanticResultKey

Eklenecek semantik anahtar.

Örnekler

Aşağıdaki örnek, bir uçuş için kaynak ve hedef şehirleri seçmeye yönelik bir konsol uygulamasının bir parçasıdır. Uygulama , "Miami'den Chicago'ya uçmak istiyorum" gibi tümcecikleri tanır. Olayın işleyicisiSpeechRecognized, kaynak ve hedef şehirler için içinde SemanticResultValue belirtilen havaalanı kodunu ayıklamak için öğesini kullanırSemanticResultKey.

using System;
using System.Speech.Recognition;

namespace SampleRecognition
{
  class Program
  {
    static void Main(string[] args)

    // Initialize an in-process speech recognition engine.
    {
      using (SpeechRecognitionEngine recognizer =
         new SpeechRecognitionEngine())
      {

        // Create a Choices object and add  cities and airport codes
        // using SemanticResultValue objects.
        Choices cities = new Choices();
        cities.Add(new SemanticResultValue("Chicago", "ORD"));
        cities.Add(new SemanticResultValue("Boston", "BOS"));
        cities.Add(new SemanticResultValue("Miami", "MIA"));
        cities.Add(new SemanticResultValue("Dallas", "DFW"));

        // Build the phrase and add SemanticResultKeys.
        GrammarBuilder chooseCities = new GrammarBuilder();
        chooseCities.Append("I want to fly from");
        chooseCities.Append(new SemanticResultKey("origin", cities));
        chooseCities.Append("to");
        chooseCities.Append(new SemanticResultKey("destination", cities));

        // Build a Grammar object from the GrammarBuilder.
        Grammar bookFlight = new Grammar(chooseCities);
        bookFlight.Name = "Book Flight";

        // Add a handler for the LoadGrammarCompleted event.
        recognizer.LoadGrammarCompleted +=
          new EventHandler<LoadGrammarCompletedEventArgs>(recognizer_LoadGrammarCompleted);

        // Add a handler for the SpeechRecognized event.
        recognizer.SpeechRecognized +=
          new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);

        // Configure the input to the recognizer.
        recognizer.SetInputToDefaultAudioDevice();

        // Load the grammar object and start recognition.
        recognizer.LoadGrammarAsync(bookFlight);
        recognizer.RecognizeAsync();

        // Keep the console window open.
        Console.ReadLine();
      }
    }

    // Handle the LoadGrammarCompleted event.
    static void recognizer_LoadGrammarCompleted(object sender, LoadGrammarCompletedEventArgs e)
    {
      Console.WriteLine("Grammar loaded: " + e.Grammar.Name);
      Console.WriteLine();
    }

    // Handle the SpeechRecognized event.
    static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {
      Console.WriteLine("Speech recognized:  " + e.Result.Text);
      Console.WriteLine();
      Console.WriteLine("Semantic results:");
      Console.WriteLine("  The flight origin is " + e.Result.Semantics["origin"].Value);
      Console.WriteLine("  The flight destination is " + e.Result.Semantics["destination"].Value);
    }
  }
}

Açıklamalar

key geçerli öğe dizisinin sonuna eklenir.

Önemli

Bir GrammarBuilder nesneye eklerken veya SemanticResultKey örnekler eklerkenSemanticResultValue, aynı anahtar adına sahip yinelenen semantik öğeler veya bir SemanticValue nesnenin özelliğini tekrar tekrar değiştirebilecek Value birden çok semantik öğe oluşturmaktan kaçının. Konuşma tanıyıcısı bu durumlarla karşılaşırsa bir özel durum oluşturabilir.

Ayrıca bkz.

Şunlara uygulanır

Append(SemanticResultValue)

Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs

Geçerli dil bilgisi öğelerinin dizisine semantik bir değer ekler.

public:
 void Append(System::Speech::Recognition::SemanticResultValue ^ value);
public void Append (System.Speech.Recognition.SemanticResultValue value);
member this.Append : System.Speech.Recognition.SemanticResultValue -> unit
Public Sub Append (value As SemanticResultValue)

Parametreler

value
SemanticResultValue

Eklenecek semantik değer.

Örnekler

Aşağıdaki örnek, bir uçuş için kaynak ve hedef şehirleri seçmeye yönelik bir konsol uygulamasının bir parçasıdır. Uygulama , "Miami'den Chicago'ya uçmak istiyorum" gibi tümcecikleri tanır. Olayın işleyicisiSpeechRecognized, kaynak ve hedef şehirler için içinde SemanticResultValue belirtilen havaalanı kodunu ayıklamak için öğesini kullanırSemanticResultKey.

using System;
using System.Speech.Recognition;

namespace SampleRecognition
{
  class Program
  {
    static void Main(string[] args)

    // Initialize an in-process speech recognition engine.
    {
      using (SpeechRecognitionEngine recognizer =
         new SpeechRecognitionEngine())
      {

        // Create GrammarBuilder objects and append SemanticResultValue objects
        // that contain cities and airport codes.

        GrammarBuilder chicago = new GrammarBuilder();
        chicago.Append(new SemanticResultValue("Chicago", "ORD"));

        GrammarBuilder boston = new GrammarBuilder();
        boston.Append(new SemanticResultValue("Boston", "BOS"));

        GrammarBuilder miami = new GrammarBuilder();
        miami.Append(new SemanticResultValue("Miami", "MIA"));

        GrammarBuilder dallas = new GrammarBuilder();
        dallas.Append(new SemanticResultValue("Dallas", "DFW"));

        // Create a Choices object and add the cities using implicit conversion from
        // SemanticResultValue to GrammarBuilder.
        Choices cities = new Choices();
        cities.Add(new Choices(new GrammarBuilder[] { chicago, boston, miami, dallas }));

        // Build the phrase and add SemanticResultKeys.
        GrammarBuilder chooseCities = new GrammarBuilder();
        chooseCities.Append("I want to fly from");
        chooseCities.Append(new SemanticResultKey("origin", cities));
        chooseCities.Append("to");
        chooseCities.Append(new SemanticResultKey("destination", cities));

        // Build a Grammar object from the GrammarBuilder.
        Grammar bookFlight = new Grammar(chooseCities);
        bookFlight.Name = "Book Flight";

        // Add a handler for the LoadGrammarCompleted event.
        recognizer.LoadGrammarCompleted +=
          new EventHandler<LoadGrammarCompletedEventArgs>(recognizer_LoadGrammarCompleted);

        // Add a handler for the SpeechRecognized event.
        recognizer.SpeechRecognized +=
          new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);

        // Configure the input to the recognizer.
        recognizer.SetInputToDefaultAudioDevice();

        // Load the grammar object and start recognition.
        recognizer.LoadGrammarAsync(bookFlight);
        recognizer.RecognizeAsync();

        // Keep the console window open.
        Console.ReadLine();
      }
    }
    // Handle the LoadGrammarCompleted event.
    static void recognizer_LoadGrammarCompleted(object sender, LoadGrammarCompletedEventArgs e)
    {
      Console.WriteLine("Grammar loaded: " + e.Grammar.Name);
      Console.WriteLine();
    }

    // Handle the SpeechRecognized event.
    static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {
      Console.WriteLine("Speech recognized:  " + e.Result.Text);
      Console.WriteLine();
      Console.WriteLine("Semantic results:");
      Console.WriteLine("  The flight origin is " + e.Result.Semantics["origin"].Value);
      Console.WriteLine("  The flight destination is " + e.Result.Semantics["destination"].Value);
    }
  }
}

Açıklamalar

value geçerli öğe dizisinin sonuna eklenir.

Önemli

Bir GrammarBuilder nesneye eklerken veya SemanticResultKey örnekler eklerkenSemanticResultValue, aynı anahtar adına sahip yinelenen semantik öğeler veya bir SemanticValue nesnenin özelliğini tekrar tekrar değiştirebilecek Value birden çok semantik öğe oluşturmaktan kaçının. Konuşma tanıyıcısı bu durumlarla karşılaşırsa bir özel durum oluşturabilir.

Ayrıca bkz.

Şunlara uygulanır

Append(GrammarBuilder)

Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs

Dil bilgisi öğesini geçerli dil bilgisi öğelerinin dizisine ekler.

public:
 void Append(System::Speech::Recognition::GrammarBuilder ^ builder);
public void Append (System.Speech.Recognition.GrammarBuilder builder);
member this.Append : System.Speech.Recognition.GrammarBuilder -> unit
Public Sub Append (builder As GrammarBuilder)

Parametreler

builder
GrammarBuilder

Eklenecek dil bilgisi öğesi.

Örnekler

Aşağıdaki örnek, "İş yerinde James'i ara" ve "Cep telefonunda Anne'yi ara" gibi ifadeler için "telefon" sözcüğünün isteğe bağlı olduğu bir konuşma tanıma dil bilgisi oluşturur. GrammarBuilder ve Choices nesneleri dil bilgisini oluşturmak için kullanılır. Örnekte yönteminin Append kullanımı vurgulanır.

public static Grammar CreatePhonePhrase()
{
  // Create alternatives for person names, locations, devices, and pronouns.
  Choices personChoice = new Choices(new string[] {"Anne", "James", "Mary", "Sam"});
  Choices locationChoice = new Choices(new string[] {"home", "work"});
  Choices deviceChoice = new Choices(new string[] {"home", "work", "cell"});
  Choices pronounChoice = new Choices(new string[] {"his", "her"});

  // Create a phrase for the receiving device, which optionally contains the word "phone".
  GrammarBuilder devicePhrase = new GrammarBuilder(pronounChoice);
  devicePhrase.Append(deviceChoice);
  devicePhrase.Append("phone", 0, 1);

  // Create alternatives for phrases specifying a device or a location.
  GrammarBuilder atLocation = new GrammarBuilder("at");
  atLocation.Append(locationChoice);

  GrammarBuilder onDevice = new GrammarBuilder("on");
  onDevice.Append(devicePhrase);

  Choices howChoice = new Choices(new GrammarBuilder[] {atLocation, onDevice});

  // Build the final phrase.
  GrammarBuilder callWho = new GrammarBuilder("Call");
  callWho.Append(personChoice);
  callWho.Append(howChoice);

  // Create the Grammar object.
  Grammar callGrammar = new Grammar(callWho);
  callGrammar.Name = "Call Grammar";

  return callGrammar;
}

Açıklamalar

builder geçerli dil bilgisi öğelerinin dizisinin sonuna eklenir.

Not

Veya içeren SemanticResultValue nesneleri veya SemanticResultKey örneklerini bir GrammarBuilder nesneye eklerkenGrammarBuilder, aynı anahtar adına sahip yinelenen semantik öğeler veya bir SemanticValue nesnenin özelliğini tekrar tekrar değiştirebilecek Value birden çok semantik öğe oluşturmaktan kaçının. Konuşma tanıyıcısı bu durumlarla karşılaşırsa bir özel durum oluşturabilir.

Ayrıca bkz.

Şunlara uygulanır

Append(Choices)

Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs
Kaynak:
GrammarBuilder.cs

Geçerli dil bilgisi öğeleri dizisine bir dizi alternatif ekler.

public:
 void Append(System::Speech::Recognition::Choices ^ alternateChoices);
public void Append (System.Speech.Recognition.Choices alternateChoices);
member this.Append : System.Speech.Recognition.Choices -> unit
Public Sub Append (alternateChoices As Choices)

Parametreler

alternateChoices
Choices

Eklenecek alternatifler kümesi.

Örnekler

Aşağıdaki örnek, "İş yerinde James'i ara" ve "Cep telefonunda Anne'yi ara" gibi ifadeler için "telefon" sözcüğünün isteğe bağlı olduğu bir konuşma tanıma dil bilgisi oluşturur. Örnekte yönteminin Append kullanımı vurgulanır.

public static Grammar CreatePhonePhrase()
{
  // Create alternatives for person names, locations, devices, and pronouns.
  Choices personChoice = new Choices(new string[] {"Anne", "James", "Mary", "Sam"});
  Choices locationChoice = new Choices(new string[] {"home", "work"});
  Choices deviceChoice = new Choices(new string[] {"home", "work", "cell"});
  Choices pronounChoice = new Choices(new string[] {"his", "her"});

  // Create a phrase for the receiving device, which optionally contains the word "phone".
  GrammarBuilder devicePhrase = new GrammarBuilder(pronounChoice);
  devicePhrase.Append(deviceChoice);
  devicePhrase.Append("phone", 0, 1);

  // Create alternatives for phrases specifying a device or a location.
  GrammarBuilder atLocation = new GrammarBuilder("at");
  atLocation.Append(locationChoice);

  GrammarBuilder onDevice = new GrammarBuilder("on");
  onDevice.Append(devicePhrase);

  Choices howChoice = new Choices(new GrammarBuilder[] {atLocation, onDevice});

  // Build the final phrase.
  GrammarBuilder callWho = new GrammarBuilder("Call");
  callWho.Append(personChoice);
  callWho.Append(howChoice);

  // Create the Grammar object.
  Grammar callGrammar = new Grammar(callWho);
  callGrammar.Name = "Call Grammar";

  return callGrammar;
}

Açıklamalar

alternateChoices geçerli öğe dizisinin sonuna eklenir.

Önemli

Veya içeren SemanticResultValue nesneleri veya SemanticResultKey örneklerini bir GrammarBuilder nesneye eklerkenChoices, aynı anahtar adına sahip yinelenen semantik öğeler veya bir SemanticValue nesnenin özelliğini tekrar tekrar değiştirebilecek Value birden çok semantik öğe oluşturmaktan kaçının. Konuşma tanıyıcısı bu durumlarla karşılaşırsa bir özel durum oluşturabilir.

Şunlara uygulanır