GrammarBuilder.Append Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Geçerli dil bilgisi öğeleri dizisine bir dil bilgisi öğesi ekler.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| Append(String, Int32, Int32) |
Geçerli dil bilgisi öğeleri dizisine yinelenen bir tümcecik ekler. |
| Append(GrammarBuilder, Int32, Int32) |
Geçerli dil bilgisi öğeleri dizisine yinelenen bir dil bilgisi öğesi 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 öğeleri dizisine ekler. |
| Append(SemanticResultKey) |
Geçerli dil bilgisi öğeleri dizisine bir semantik anahtar ekler. |
| Append(SemanticResultValue) |
Geçerli dil bilgisi öğeleri dizisine semantik bir değer ekler. |
| Append(GrammarBuilder) |
Geçerli dil bilgisi öğeleri dizisine bir dil bilgisi öğesi 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 eklemek GrammarBuilderiçin aşırı yüklemeleri vardır.
Önemli
Konuşma tanıma, aynı anahtar adına sahip yinelenen semantik öğeler veya aynı semantik öğenin değerini tekrar tekrar değiştirebilen birden çok semantik öğe içeren bir konuşma tanıma dil bilgisi kullanırken bir ö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
- 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 sözcüklerin tekrarlanan 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
Giriş eşleştirmesinin phrase eşleşme oluşturması için en fazla kaç kez gerçekleşebileceği.
Örnekler
Aşağıdaki örnek, "İş yerinde James'i ara" ve "Cep telefonundan 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öntemin 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'a eşit veya ondan büyük ve değerinden maxRepeatküçük veya buna eşit olmalıdır.
Ayrıca bkz.
Şunlara uygulanır
Append(GrammarBuilder, Int32, Int32)
- Kaynak:
- GrammarBuilder.cs
- Kaynak:
- GrammarBuilder.cs
- Kaynak:
- GrammarBuilder.cs
- Kaynak:
- GrammarBuilder.cs
Geçerli dil bilgisi öğeleri dizisine yinelenen bir dil bilgisi öğesi 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ı için en az kaç kez gerçekleşmesi gerekir.
- maxRepeat
- Int32
tarafından tanımlanan builder öğeyle eşleşen girişin eşleşme oluşturabileceği en fazla sayı.
Örnekler
Aşağıdaki örnek, "İş yerinde James'i ara" ve "Cep telefonundan 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öntemin 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'a eşit veya ondan büyük ve değerinden maxRepeatküçük veya buna eşit olmalıdır.
Önemli
Veya içeren SemanticResultValue nesneleri veya SemanticResultKey örnekleri bir GrammarBuilder nesneye eklediğinizdeGrammarBuilder, aynı anahtar adına sahip yinelenen anlamsal öğeler veya bir SemanticValue nesnenin özelliğini tekrar tekrar değiştirebilecek Value birden çok anlam öğesi oluşturmaktan kaçının. Konuşma tanıyıcı, 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
- 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
- Kaynak:
- GrammarBuilder.cs
Bir tümceciği alt kümesi için bir öğeyi geçerli dil bilgisi öğeleri 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ş" ifadelerini 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
- Kaynak:
- GrammarBuilder.cs
Geçerli dil bilgisi öğeleri dizisine bir semantik 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
Eklenecek semantik anahtar.
Örnekler
Aşağıdaki örnek, bir uçuş için çıkış ve hedef şehirleri seçmeye yönelik bir konsol uygulamasının parçasıdır. Uygulama , "Miami'den Chicago'ya uçmak istiyorum" gibi tümcecikleri tanır. Olayın işleyicisiSpeechRecognized, kaynağı ve hedef şehirleri 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 SemanticResultValue veya SemanticResultKey örnekler eklerken, aynı anahtar adına veya bir nesnenin özelliğini SemanticValue tekrar tekrar değiştirebilecek Value birden çok semantik öğeye sahip yinelenen semantik öğeler oluşturmaktan kaçının. Konuşma tanıyıcı, 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
- Kaynak:
- GrammarBuilder.cs
Geçerli dil bilgisi öğeleri 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 çıkış ve hedef şehirleri seçmeye yönelik bir konsol uygulamasının parçasıdır. Uygulama , "Miami'den Chicago'ya uçmak istiyorum" gibi tümcecikleri tanır. Olayın işleyicisiSpeechRecognized, kaynağı ve hedef şehirleri 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 SemanticResultValue veya SemanticResultKey örnekler eklerken, aynı anahtar adına veya bir nesnenin özelliğini SemanticValue tekrar tekrar değiştirebilecek Value birden çok semantik öğeye sahip yinelenen semantik öğeler oluşturmaktan kaçının. Konuşma tanıyıcı, 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
- Kaynak:
- GrammarBuilder.cs
Geçerli dil bilgisi öğeleri dizisine bir dil bilgisi öğesi 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 dilbilgisi öğesi.
Örnekler
Aşağıdaki örnek, "İş yerinde James'i ara" ve "Cep telefonundan 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öntemin 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.
Uyarı
Veya içeren SemanticResultValue nesneleri veya SemanticResultKey örnekleri bir GrammarBuilder nesneye eklediğinizdeGrammarBuilder, aynı anahtar adına sahip yinelenen anlamsal öğeler veya bir SemanticValue nesnenin özelliğini tekrar tekrar değiştirebilecek Value birden çok anlam öğesi oluşturmaktan kaçının. Konuşma tanıyıcı, 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
- 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 telefonundan 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öntemin 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 örnekleri bir GrammarBuilder nesneye eklediğinizdeChoices, aynı anahtar adına sahip yinelenen anlamsal öğeler veya bir SemanticValue nesnenin özelliğini tekrar tekrar değiştirebilecek Value birden çok anlam öğesi oluşturmaktan kaçının. Konuşma tanıyıcı, bu durumlarla karşılaşırsa bir özel durum oluşturabilir.