Udostępnij za pośrednictwem


GrammarBuilder.Add Metoda

Definicja

Tworzy nowy GrammarBuilder element zawierający sekwencję dwóch elementów gramatycznych.

Przeciążenia

Nazwa Opis
Add(Choices, GrammarBuilder)

Tworzy nowy GrammarBuilder obiekt zawierający Choices obiekt, po którym następuje GrammarBuilder obiekt.

Add(GrammarBuilder, Choices)

Tworzy nowy GrammarBuilder obiekt zawierający GrammarBuilder obiekt, po którym następuje Choices obiekt.

Add(GrammarBuilder, GrammarBuilder)

Tworzy nową GrammarBuilder , która zawiera sekwencję dwóch GrammarBuilder obiektów.

Add(GrammarBuilder, String)

Tworzy nowy GrammarBuilder obiekt zawierający GrammarBuilder obiekt, po którym następuje fraza.

Add(String, GrammarBuilder)

Tworzy nowy GrammarBuilder element zawierający frazę, po której następuje GrammarBuilder obiekt.

Uwagi

Metody statyczne Add zapewniają inny mechanizm, za pomocą którego można połączyć różne typy, aby tworzyć różnorodność i elastyczność gramatyki skompilowanych za pomocą GrammarBuilderpolecenia . Te metody odpowiadają metodom statycznym Addition , które są również zdefiniowane w GrammarBuilder klasie. Kolejność parametrów określa kolejność elementów w nowym GrammarBuilderobiekcie .

Obiekt GrammarBuilder można również uzyskać z Choicesobiektów , SemanticResultKey, SemanticResultValuei String . Aby uzyskać więcej informacji, zobacz Implicit operatory i Addition .

Ważna

Rozpoznawanie mowy może zgłosić wyjątek podczas korzystania z gramatyki rozpoznawania mowy zawierającej zduplikowane elementy semantyczne o tej samej nazwie klucza lub wielu elementach semantycznych, które mogą wielokrotnie modyfikować wartość tego samego elementu semantycznego.

Aby uzyskać więcej informacji na temat tworzenia i używania gramatyki rozpoznawania mowy, zobacz Rozpoznawanie mowy.

Add(Choices, GrammarBuilder)

Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs

Tworzy nowy GrammarBuilder obiekt zawierający Choices obiekt, po którym następuje GrammarBuilder obiekt.

public:
 static System::Speech::Recognition::GrammarBuilder ^ Add(System::Speech::Recognition::Choices ^ choices, System::Speech::Recognition::GrammarBuilder ^ builder);
public static System.Speech.Recognition.GrammarBuilder Add(System.Speech.Recognition.Choices choices, System.Speech.Recognition.GrammarBuilder builder);
static member Add : System.Speech.Recognition.Choices * System.Speech.Recognition.GrammarBuilder -> System.Speech.Recognition.GrammarBuilder
Public Shared Function Add (choices As Choices, builder As GrammarBuilder) As GrammarBuilder

Parametry

choices
Choices

Pierwszy element gramatyczny, który reprezentuje zestaw alternatyw.

builder
GrammarBuilder

Drugi element gramatyki.

Zwraca

A GrammarBuilder dla sekwencji choices elementu, po którym następuje builder element.

Uwagi

GrammarBuilder obsługuje niejawne konwersje z następujących klas:

Ta metoda akceptuje obiekty wymienione powyżej dla parametru builder .

Aby uzyskać więcej informacji, zobacz Implicit operatory i Addition .

Ważna

Podczas łączenia Choices obiektów GrammarBuilder zawierających SemanticResultValue lub SemanticResultKey wystąpień należy unikać tworzenia zduplikowanych elementów semantycznych o tej samej nazwie klucza lub wielu elementach semantycznych, które mogą wielokrotnie modyfikować Value właściwość SemanticValue obiektu. Rozpoznawanie mowy może zgłosić wyjątek, jeśli napotka te okoliczności. Aby uzyskać więcej informacji na temat tworzenia gramatyki rozpoznawania mowy zawierającej informacje semantyczne, zobacz Dodawanie semantyki do gramatyki GrammarBuilder.

Zobacz też

Dotyczy

Add(GrammarBuilder, Choices)

Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs

Tworzy nowy GrammarBuilder obiekt zawierający GrammarBuilder obiekt, po którym następuje Choices obiekt.

public:
 static System::Speech::Recognition::GrammarBuilder ^ Add(System::Speech::Recognition::GrammarBuilder ^ builder, System::Speech::Recognition::Choices ^ choices);
public static System.Speech.Recognition.GrammarBuilder Add(System.Speech.Recognition.GrammarBuilder builder, System.Speech.Recognition.Choices choices);
static member Add : System.Speech.Recognition.GrammarBuilder * System.Speech.Recognition.Choices -> System.Speech.Recognition.GrammarBuilder
Public Shared Function Add (builder As GrammarBuilder, choices As Choices) As GrammarBuilder

Parametry

builder
GrammarBuilder

Pierwszy element gramatyki.

choices
Choices

Drugi element gramatyczny, który reprezentuje zestaw alternatyw.

Zwraca

A GrammarBuilder dla sekwencji builder elementu, po którym następuje choices element.

Przykłady

W poniższym przykładzie tworzona jest gramatyka rozpoznawania mowy, która umożliwia rozpoznawanie dwóch fraz: "Make background color" (Ustaw kolor tła na kolor), gdzie kolor jest wybierany z zestawu kolorów. Różne typy służą do kompilowania ostatecznej gramatyki, takiej jak Ciąg, Choicesi GrammarBuilder obiekty. Jawne operatory rzutowania w wywołaniach metod Add są opcjonalne.

private Grammar CreateColorGrammar()
{

  // Create a set of color choices.
  Choices colorChoice = new Choices(new string[] {"red", "green", "blue"});

  // Create grammar builders for the two versions of the phrase.
  GrammarBuilder makePhrase =
    GrammarBuilder.Add((GrammarBuilder)"Make background", colorChoice);
  GrammarBuilder setPhrase =
    GrammarBuilder.Add("Set background to", (GrammarBuilder)colorChoice);

  // Create a Choices for the two alternative phrases, convert the Choices
  // to a GrammarBuilder, and construct the grammar from the result.
  Choices bothChoices = new Choices(new GrammarBuilder[] {makePhrase, setPhrase});
  GrammarBuilder bothPhrases = new GrammarBuilder(bothChoices);

  Grammar grammar = new Grammar(bothPhrases);
  grammar.Name = "backgroundColor";
  return grammar;
}

Uwagi

GrammarBuilder obsługuje niejawne konwersje z następujących klas:

Ta metoda akceptuje obiekty wymienione powyżej dla parametru builder .

Aby uzyskać więcej informacji, zobacz Implicit operatory i Addition .

Ważna

Podczas łączenia Choices obiektów i GrammarBuilder zawierających SemanticResultValue wystąpienia lub SemanticResultKey z innymi elementami gramatycznymi należy unikać tworzenia zduplikowanych elementów semantycznych o tej samej nazwie klucza lub wielu elementach semantycznych, które mogą wielokrotnie modyfikować Value właściwość SemanticValue obiektu. Rozpoznawanie mowy może zgłosić wyjątek, jeśli napotka te okoliczności.

Zobacz też

Dotyczy

Add(GrammarBuilder, GrammarBuilder)

Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs

Tworzy nową GrammarBuilder , która zawiera sekwencję dwóch GrammarBuilder obiektów.

public:
 static System::Speech::Recognition::GrammarBuilder ^ Add(System::Speech::Recognition::GrammarBuilder ^ builder1, System::Speech::Recognition::GrammarBuilder ^ builder2);
public static System.Speech.Recognition.GrammarBuilder Add(System.Speech.Recognition.GrammarBuilder builder1, System.Speech.Recognition.GrammarBuilder builder2);
static member Add : System.Speech.Recognition.GrammarBuilder * System.Speech.Recognition.GrammarBuilder -> System.Speech.Recognition.GrammarBuilder
Public Shared Function Add (builder1 As GrammarBuilder, builder2 As GrammarBuilder) As GrammarBuilder

Parametry

builder1
GrammarBuilder

Pierwszy element gramatyki.

builder2
GrammarBuilder

Drugi element gramatyki.

Zwraca

A GrammarBuilder dla sekwencji builder1 elementu, po którym następuje builder2 element.

Przykłady

W poniższym przykładzie tworzona jest gramatyka rozpoznawania mowy, która umożliwia rozpoznawanie dwóch fraz: "Make background color" (Ustaw kolor tła na kolor), gdzie kolor jest wybierany z zestawu kolorów. Różne typy służą do kompilowania ostatecznej gramatyki, takiej jak Ciąg, Choicesi GrammarBuilder obiekty. Jawne operatory rzutowania w wywołaniach metod Add są opcjonalne.

private Grammar CreateColorGrammar()
{

  // Create a set of color choices.
  Choices colorChoice = new Choices(new string[] {"red", "green", "blue"});

  // Create grammar builders for the two versions of the phrase.
  GrammarBuilder makePhrase =
    GrammarBuilder.Add((GrammarBuilder)"Make background", colorChoice);
  GrammarBuilder setPhrase =
    GrammarBuilder.Add("Set background to", (GrammarBuilder)colorChoice);

  // Create a Choices for the two alternative phrases, convert the Choices
  // to a GrammarBuilder, and construct the grammar from the result.
  Choices bothChoices = new Choices(new GrammarBuilder[] {makePhrase, setPhrase});
  GrammarBuilder bothPhrases = new GrammarBuilder(bothChoices);

  Grammar grammar = new Grammar(bothPhrases);
  grammar.Name = "backgroundColor";
  return grammar;
}

Uwagi

GrammarBuilder obsługuje niejawne konwersje z następujących klas:

Ta metoda akceptuje obiekty wymienione powyżej dla parametru builder1 or builder2 .

Aby uzyskać więcej informacji, zobacz Implicit operatory i Addition .

Ważna

Podczas łączenia Choices obiektów i GrammarBuilder zawierających SemanticResultValue wystąpienia lub SemanticResultKey z innymi elementami gramatycznymi należy unikać tworzenia zduplikowanych elementów semantycznych o tej samej nazwie klucza lub wielu elementach semantycznych, które mogą wielokrotnie modyfikować Value właściwość SemanticValue obiektu. Rozpoznawanie mowy może zgłosić wyjątek, jeśli napotka te okoliczności.

Zobacz też

Dotyczy

Add(GrammarBuilder, String)

Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs

Tworzy nowy GrammarBuilder obiekt zawierający GrammarBuilder obiekt, po którym następuje fraza.

public:
 static System::Speech::Recognition::GrammarBuilder ^ Add(System::Speech::Recognition::GrammarBuilder ^ builder, System::String ^ phrase);
public static System.Speech.Recognition.GrammarBuilder Add(System.Speech.Recognition.GrammarBuilder builder, string phrase);
static member Add : System.Speech.Recognition.GrammarBuilder * string -> System.Speech.Recognition.GrammarBuilder
Public Shared Function Add (builder As GrammarBuilder, phrase As String) As GrammarBuilder

Parametry

builder
GrammarBuilder

Pierwszy element gramatyki.

phrase
String

Drugi element gramatyki, który reprezentuje sekwencję wyrazów.

Zwraca

A GrammarBuilder dla sekwencji builder elementu, po którym następuje phrase element.

Przykłady

W poniższym przykładzie tworzona jest gramatyka rozpoznawania mowy, która umożliwia rozpoznawanie dwóch fraz: "Make background color" (Ustaw kolor tła na kolor), gdzie kolor jest wybierany z zestawu kolorów. Różne typy służą do kompilowania ostatecznej gramatyki, takiej jak Ciąg, Choicesi GrammarBuilder obiekty. Jawne operatory rzutowania w wywołaniach metod Add są opcjonalne.

private Grammar CreateColorGrammar()
{

  // Create a set of color choices.
  Choices colorChoice = new Choices(new string[] {"red", "green", "blue"});

  // Create grammar builders for the two versions of the phrase.
  GrammarBuilder makePhrase =
    GrammarBuilder.Add((GrammarBuilder)"Make background", colorChoice);
  GrammarBuilder setPhrase =
    GrammarBuilder.Add("Set background to", (GrammarBuilder)colorChoice);

  // Create a Choices for the two alternative phrases, convert the Choices
  // to a GrammarBuilder, and construct the grammar from the result.
  Choices bothChoices = new Choices(new GrammarBuilder[] {makePhrase, setPhrase});
  GrammarBuilder bothPhrases = new GrammarBuilder(bothChoices);

  Grammar grammar = new Grammar(bothPhrases);
  grammar.Name = "backgroundColor";
  return grammar;
}

Uwagi

GrammarBuilder obsługuje niejawne konwersje z następujących klas:

Ta metoda akceptuje obiekty wymienione powyżej dla parametru builder .

Aby uzyskać więcej informacji, zobacz Implicit operatory i Addition .

Zobacz też

Dotyczy

Add(String, GrammarBuilder)

Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs
Źródło:
GrammarBuilder.cs

Tworzy nowy GrammarBuilder element zawierający frazę, po której następuje GrammarBuilder obiekt.

public:
 static System::Speech::Recognition::GrammarBuilder ^ Add(System::String ^ phrase, System::Speech::Recognition::GrammarBuilder ^ builder);
public static System.Speech.Recognition.GrammarBuilder Add(string phrase, System.Speech.Recognition.GrammarBuilder builder);
static member Add : string * System.Speech.Recognition.GrammarBuilder -> System.Speech.Recognition.GrammarBuilder
Public Shared Function Add (phrase As String, builder As GrammarBuilder) As GrammarBuilder

Parametry

phrase
String

Pierwszy element gramatyki, który reprezentuje sekwencję wyrazów.

builder
GrammarBuilder

Drugi element gramatyki.

Zwraca

A GrammarBuilder dla sekwencji phrase elementu, po którym następuje builder element.

Przykłady

W poniższym przykładzie tworzona jest gramatyka rozpoznawania mowy, która umożliwia rozpoznawanie dwóch fraz: "Make background color" (Ustaw kolor tła na kolor), gdzie kolor jest wybierany z zestawu kolorów. Różne typy służą do kompilowania ostatecznej gramatyki, takiej jak Ciąg, Choicesi GrammarBuilder obiekty. Jawne operatory rzutowania w wywołaniach metod Add są opcjonalne.

private Grammar CreateColorGrammar()
{

  // Create a set of color choices.
  Choices colorChoice = new Choices(new string[] {"red", "green", "blue"});

  // Create grammar builders for the two versions of the phrase.
  GrammarBuilder makePhrase =
    GrammarBuilder.Add((GrammarBuilder)"Make background", colorChoice);
  GrammarBuilder setPhrase =
    GrammarBuilder.Add("Set background to", (GrammarBuilder)colorChoice);

  // Create a Choices for the two alternative phrases, convert the Choices
  // to a GrammarBuilder, and construct the grammar from the result.
  Choices bothChoices = new Choices(new GrammarBuilder[] {makePhrase, setPhrase});
  GrammarBuilder bothPhrases = new GrammarBuilder(bothChoices);

  Grammar grammar = new Grammar(bothPhrases);
  grammar.Name = "backgroundColor";
  return grammar;
}

Uwagi

GrammarBuilder obsługuje niejawne konwersje z następujących klas:

Ta metoda akceptuje obiekty wymienione powyżej dla parametru builder .

Aby uzyskać więcej informacji, zobacz Implicit operatory i Addition .

Zobacz też

Dotyczy