Choices Oluşturucular
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.
Choices sınıfının yeni bir örneğini başlatır.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| Choices() |
Boş bir alternatif kümesi içeren sınıfın yeni bir örneğini Choices başlatır. |
| Choices(GrammarBuilder[]) |
Bir veya daha fazla Choices nesne içeren bir diziden sınıfının yeni bir örneğini GrammarBuilder başlatır. |
| Choices(String[]) |
Bir veya daha fazla Choices nesne içeren bir diziden sınıfının yeni bir örneğini String başlatır. |
Örnekler
Aşağıdaki örnek, iki alternatif listesi oluşturmak için nesneleri kullanır Choices .
İlk Choices nesne bir nesne dizisinden String oluşturulur. Diğer Choices nesne, örtük olarak bir atama tarafından dönüştürülen bir nesne dizisinden GrammarBuilder oluşturulur.
Örnek, nesneleri ve iki ek dizeyi GrammarBuilder kullanarak bir tümceciği bir araya getirmek için bir Choices nesne kullanır. Bu, "[phoneType] telefonunda [contactlList] çağrısı" biçimindeki konuşma girişini tanımak için kullanılabilir, örneğin "Cep telefonunda Jane'i ara".
public GrammarBuilder ChoicesConstructor2 ()
{
GrammarBuilder gb = new GrammarBuilder ();
Choices phoneType = new Choices (new string[] {"cell", "home", "work"});
Choices contactList = new Choices (new GrammarBuilder[] {(GrammarBuilder) "Mark", (GrammarBuilder) "Jane", (GrammarBuilder) "Frank"});
gb.Append ("Call");
gb.Append (contactList);
gb.Append ("on");
gb.Append (phoneType);
gb.Append ("phone");
return gb;
}
Açıklamalar
Parametresiz bir oluşturucu (boş bir nesne döndüren), bir nesne grubundan Choices veya nesne kümesinden String bir nesne oluşturabilirsinizGrammarBuilder.
nesnesi ve GrammarBuilderöğesinden örtük dönüştürmeyi SemanticResultValue desteklediğindenSemanticResultKey, Choices bu nesnelerin dizisinden bir atama kullanılarak bir oluşturulabilir.
Choices()
- Kaynak:
- Choices.cs
- Kaynak:
- Choices.cs
- Kaynak:
- Choices.cs
- Kaynak:
- Choices.cs
Boş bir alternatif kümesi içeren sınıfın yeni bir örneğini Choices başlatır.
public:
Choices();
public Choices();
Public Sub New ()
Örnekler
Aşağıdaki örnek, ve Choices nesnelerini kullanarak GrammarBuilder "Cep telefonunda Anne'yi ara" ve "İş telefonunda James'i ara" gibi konuşma girişini tanımak için kullanılabilecek bir tümcecik oluşturur. Örnek, ve'den ChoicesString öğesine GrammarBuilderörtük atamalar kullanır.
public Grammar CreatePhonePhrase()
{
// Create alternatives for female names and add a phrase.
GrammarBuilder females = new Choices(new string[] { "Anne", "Mary" });
females.Append("on her");
// Create alternatives for male names and add a phrase.
GrammarBuilder males = new Choices(new string[] { "James", "Sam" });
males.Append("on his");
// Create a Choices object that contains an array of alternative
// GrammarBuilder objects.
Choices people = new Choices();
people.Add(new Choices(new GrammarBuilder[] {females, males}));
// Create a Choices object that contains a set of alternative phone types.
Choices phoneType = new Choices();
phoneType.Add(new string[] { "cell", "home", "work" });
// Construct the phrase.
GrammarBuilder gb = new GrammarBuilder();
gb.Append("call");
gb.Append(people);
gb.Append(phoneType);
gb.Append(new GrammarBuilder("phone"), 0, 1);
return new Grammar(gb);
}
Açıklamalar
Bu oluşturucu geçerli, boş bir alternatif kümesi döndürür. Yöntemlerden herhangi birini Add kullanarak alternatifler ekleyebilirsiniz.
Ayrıca bkz.
Şunlara uygulanır
Choices(GrammarBuilder[])
- Kaynak:
- Choices.cs
- Kaynak:
- Choices.cs
- Kaynak:
- Choices.cs
- Kaynak:
- Choices.cs
Bir veya daha fazla Choices nesne içeren bir diziden sınıfının yeni bir örneğini GrammarBuilder başlatır.
public:
Choices(... cli::array <System::Speech::Recognition::GrammarBuilder ^> ^ alternateChoices);
public Choices(params System.Speech.Recognition.GrammarBuilder[] alternateChoices);
new System.Speech.Recognition.Choices : System.Speech.Recognition.GrammarBuilder[] -> System.Speech.Recognition.Choices
Public Sub New (ParamArray alternateChoices As GrammarBuilder())
Parametreler
- alternateChoices
- GrammarBuilder[]
Alternatifler kümesini içeren bir dizi.
Örnekler
Aşağıdaki örnek, ve nesnelerini kullanarak Choices "Cep telefonunda Anne'i Ara" ve "İş telefonunda James'i ara" gibi ifadeler oluştururGrammarBuilder.Grammar Örnek, ve'den ChoicesString öğesine GrammarBuilderörtük atamalar kullanır.
public Grammar CreatePhonePhrase()
{
// Create alternatives for female names and add a phrase.
GrammarBuilder females = new Choices(new string[] { "Anne", "Mary" });
females.Append("on her");
// Create alternatives for male names and add a phrase.
GrammarBuilder males = new Choices(new string[] { "James", "Sam" });
males.Append("on his");
// Create a Choices object that contains an array of alternative
// GrammarBuilder objects.
Choices people = new Choices();
people.Add(new Choices(new GrammarBuilder[] {females, males}));
// Create a Choices object that contains a set of alternative phone types.
Choices phoneType = new Choices();
phoneType.Add(new string[] { "cell", "home", "work" });
// Construct the phrase.
GrammarBuilder gb = new GrammarBuilder();
gb.Append("call");
gb.Append(people);
gb.Append(phoneType);
gb.Append(new GrammarBuilder("phone"), 0, 1);
return new Grammar(gb);
}
Açıklamalar
içindeki GrammarBuilder her alternateChoices biri bir alternatif tanımlar. Boş bir diziyse alternateChoices , oluşturucu boş bir alternatif kümesi döndürür. Yöntemlerden herhangi birini Add kullanarak alternatifler ekleyebilirsiniz.
Oluşturucu, dizi öğelerinin ArgumentNullExceptionherhangi biri olduğunda alternateChoicesnull veya olduğunda oluştururnull.
GrammarBuilder sınıfı, , ve Choices nesnelerinin örneklere örtük olarak dönüştürülmesi SemanticResultValueSemanticResultKeyGrammarBuilder için destek sağladığından, atamaları düzgün bir şekilde kullanarak bu oluşturucu, bu nesnelerin herhangi bir Choices bileşiminden bir nesne oluşturmak için de kullanılabilir.
Ayrıca bkz.
Şunlara uygulanır
Choices(String[])
- Kaynak:
- Choices.cs
- Kaynak:
- Choices.cs
- Kaynak:
- Choices.cs
- Kaynak:
- Choices.cs
public:
Choices(... cli::array <System::String ^> ^ phrases);
public Choices(params string[] phrases);
new System.Speech.Recognition.Choices : string[] -> System.Speech.Recognition.Choices
Public Sub New (ParamArray phrases As String())
Parametreler
- phrases
- String[]
Alternatifler kümesini içeren bir dizi.
Örnekler
Aşağıdaki örnek, "Cep telefonunda Anne'i Ara" ve "İş telefonunda James'i ara" gibi ifadeler için bir Choices oluşturmak üzere ve GrammarBuilder nesnelerini kullanırGrammar. Örnek, ve'den ChoicesString öğesine GrammarBuilderörtük atamalar kullanır.
public Grammar CreatePhonePhrase()
{
// Create alternatives for female names and add a phrase.
GrammarBuilder females = new Choices(new string[] { "Anne", "Mary" });
females.Append("on her");
// Create alternatives for male names and add a phrase.
GrammarBuilder males = new Choices(new string[] { "James", "Sam" });
males.Append("on his");
// Create a Choices object that contains an array of alternative
// GrammarBuilder objects.
Choices people = new Choices();
people.Add(new Choices(new GrammarBuilder[] {females, males}));
// Create a Choices object that contains a set of alternative phone types.
Choices phoneType = new Choices();
phoneType.Add(new string[] { "cell", "home", "work" });
// Construct the phrase.
GrammarBuilder gb = new GrammarBuilder();
gb.Append("call");
gb.Append(people);
gb.Append(phoneType);
gb.Append(new GrammarBuilder("phone"), 0, 1);
return new Grammar(gb);
}
Açıklamalar
içindeki String her phrases biri bir alternatif tanımlar. Konuşma tanıma altyapısı, konuşma girişiyle eşleştirmek için dize dizisindeki öğelerden herhangi birini kullanabilir. Boş bir diziyse phrases , oluşturucu boş bir alternatif kümesi döndürür. Yöntemlerden herhangi birini Add kullanarak alternatifler ekleyebilirsiniz.
Oluşturucu, ArgumentNullException olduğunda veya dizi öğelerinden herhangi biri olduğunda phrasesnull oluştururnull. Oluşturucu, dizideki herhangi bir ArgumentException öğe boş bir dize ("") ise bir eğer oluşturur.