GrammarBuilder.Addition Operator
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates a new GrammarBuilder that corresponds to a sequence of two grammar elements.
Overloads
Addition(Choices, GrammarBuilder) |
Creates a new GrammarBuilder that contains a Choices object followed by a GrammarBuilder object. |
Addition(GrammarBuilder, Choices) |
Creates a new GrammarBuilder that contains a GrammarBuilder followed by a Choices. |
Addition(GrammarBuilder, GrammarBuilder) |
Creates a new GrammarBuilder that contains a sequence of two GrammarBuilder objects. |
Addition(GrammarBuilder, String) |
Creates a new GrammarBuilder that contains a GrammarBuilder followed by a phrase. |
Addition(String, GrammarBuilder) |
Creates a new GrammarBuilder that contains a phrase followed by a GrammarBuilder. |
Remarks
The order of the operands determines the order of the elements in the new GrammarBuilder.
Important
Caution is recommended when combining Choices or GrammarBuilder objects that contain SemanticResultValue or SemanticResultKey instances with other grammar elements. The speech recognizer can throw an exception when using a speech recognition grammar that contains duplicate semantic elements with the same key name or multiple semantic elements that could repeatedly modify the value of the same semantic element.
For more information about building and using speech recognition grammars, see Speech Recognition.
Addition(Choices, GrammarBuilder)
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
Creates a new GrammarBuilder that contains a Choices object followed by a GrammarBuilder object.
public:
static System::Speech::Recognition::GrammarBuilder ^ operator +(System::Speech::Recognition::Choices ^ choices, System::Speech::Recognition::GrammarBuilder ^ builder);
public static System.Speech.Recognition.GrammarBuilder operator + (System.Speech.Recognition.Choices choices, System.Speech.Recognition.GrammarBuilder builder);
static member ( + ) : System.Speech.Recognition.Choices * System.Speech.Recognition.GrammarBuilder -> System.Speech.Recognition.GrammarBuilder
Public Shared Operator + (choices As Choices, builder As GrammarBuilder) As GrammarBuilder
Parameters
- choices
- Choices
The first grammar element, which represents a set of alternatives.
- builder
- GrammarBuilder
The second grammar element.
Returns
Returns a GrammarBuilder for the sequence of the choices
parameter followed by the builder
parameter.
Remarks
GrammarBuilder supports conversions from the following classes.
This method accepts the objects listed above for the builder
parameter. For more information, see the Implicit operators.
Important
When you combine Choices and GrammarBuilder objects that contain SemanticResultValue or SemanticResultKey instances, make sure you avoid creating duplicate semantic elements with the same key name or multiple semantic elements that could repeatedly modify the Value property of a SemanticValue object. The speech recognizer can throw an exception if it encounters these circumstances.
The equivalent method for this operator is GrammarBuilder.Add(Choices, GrammarBuilder)
See also
Applies to
Addition(GrammarBuilder, Choices)
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
Creates a new GrammarBuilder that contains a GrammarBuilder followed by a Choices.
public:
static System::Speech::Recognition::GrammarBuilder ^ operator +(System::Speech::Recognition::GrammarBuilder ^ builder, System::Speech::Recognition::Choices ^ choices);
public static System.Speech.Recognition.GrammarBuilder operator + (System.Speech.Recognition.GrammarBuilder builder, System.Speech.Recognition.Choices choices);
static member ( + ) : System.Speech.Recognition.GrammarBuilder * System.Speech.Recognition.Choices -> System.Speech.Recognition.GrammarBuilder
Public Shared Operator + (builder As GrammarBuilder, choices As Choices) As GrammarBuilder
Parameters
- builder
- GrammarBuilder
The first grammar element.
- choices
- Choices
The second grammar element, which represents a set of alternative elements.
Returns
Returns a GrammarBuilder for the sequence of the builder
parameter followed by the choices
parameter.
Examples
The following example creates a speech recognition grammar that can recognize the two phrases, "Make background color" and "Set background to color", where color is selected from a set of colors. Various types are used to build the final grammar, such as String, Choices, and GrammarBuilder objects.
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)"Make background" + colorChoice;
GrammarBuilder setPhrase =
"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;
}
Remarks
GrammarBuilder supports conversions from the following classes:
This method accepts the objects listed above for the builder
parameter. For more information, see the Implicit operators.
Important
When you combine Choices and GrammarBuilder objects that contain SemanticResultValue or SemanticResultKey instances, make sure you avoid creating duplicate semantic elements with the same key name or multiple semantic elements that could repeatedly modify the Value property of a SemanticValue object. The speech recognizer can throw an exception if it encounters these circumstances.
The equivalent method for this operator is GrammarBuilder.Add(GrammarBuilder, Choices)
See also
Applies to
Addition(GrammarBuilder, GrammarBuilder)
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
Creates a new GrammarBuilder that contains a sequence of two GrammarBuilder objects.
public:
static System::Speech::Recognition::GrammarBuilder ^ operator +(System::Speech::Recognition::GrammarBuilder ^ builder1, System::Speech::Recognition::GrammarBuilder ^ builder2);
public static System.Speech.Recognition.GrammarBuilder operator + (System.Speech.Recognition.GrammarBuilder builder1, System.Speech.Recognition.GrammarBuilder builder2);
static member ( + ) : System.Speech.Recognition.GrammarBuilder * System.Speech.Recognition.GrammarBuilder -> System.Speech.Recognition.GrammarBuilder
Public Shared Operator + (builder1 As GrammarBuilder, builder2 As GrammarBuilder) As GrammarBuilder
Parameters
- builder1
- GrammarBuilder
The first grammar element.
- builder2
- GrammarBuilder
The second grammar element.
Returns
Returns a GrammarBuilder for the sequence of the builder1
parameter followed by the builder2
parameter.
Remarks
GrammarBuilder supports conversions from the following classes.
This method accepts the objects listed above for the builder1
and builder2
parameters. For more information, see the Implicit operators.
Important
When you combine GrammarBuilder objects that contain SemanticResultValue or SemanticResultKey instances, make sure you avoid creating duplicate semantic elements with the same key name or multiple semantic elements that could repeatedly modify the Value property of a SemanticValue object. The speech recognizer can throw an exception if it encounters these circumstances.
The equivalent method for this operator is GrammarBuilder.Add(GrammarBuilder, GrammarBuilder)
See also
Applies to
Addition(GrammarBuilder, String)
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
Creates a new GrammarBuilder that contains a GrammarBuilder followed by a phrase.
public:
static System::Speech::Recognition::GrammarBuilder ^ operator +(System::Speech::Recognition::GrammarBuilder ^ builder, System::String ^ phrase);
public static System.Speech.Recognition.GrammarBuilder operator + (System.Speech.Recognition.GrammarBuilder builder, string phrase);
static member ( + ) : System.Speech.Recognition.GrammarBuilder * string -> System.Speech.Recognition.GrammarBuilder
Public Shared Operator + (builder As GrammarBuilder, phrase As String) As GrammarBuilder
Parameters
- builder
- GrammarBuilder
The first grammar element.
- phrase
- String
The second grammar element, which represents a sequence of words.
Returns
Returns a GrammarBuilder for the sequence of the builder
parameter followed by the phrase
parameter.
Remarks
GrammarBuilder supports conversions from the following classes.
This method accepts the objects listed above for the builder
parameter. For more information, see the Implicit operators.
The equivalent method for this operator is GrammarBuilder.Add(GrammarBuilder, String)
See also
Applies to
Addition(String, GrammarBuilder)
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
Creates a new GrammarBuilder that contains a phrase followed by a GrammarBuilder.
public:
static System::Speech::Recognition::GrammarBuilder ^ operator +(System::String ^ phrase, System::Speech::Recognition::GrammarBuilder ^ builder);
public static System.Speech.Recognition.GrammarBuilder operator + (string phrase, System.Speech.Recognition.GrammarBuilder builder);
static member ( + ) : string * System.Speech.Recognition.GrammarBuilder -> System.Speech.Recognition.GrammarBuilder
Public Shared Operator + (phrase As String, builder As GrammarBuilder) As GrammarBuilder
Parameters
- phrase
- String
The first grammar element, which represents a sequence of words.
- builder
- GrammarBuilder
The second grammar element.
Returns
Returns a GrammarBuilder for the sequence of the phrase
parameter followed by the builder
parameter.
Examples
The following example creates a speech recognition grammar that can recognize the two phrases, "Make background color" and "Set background to color", where color is selected from a set of colors. Various types are used to build the final grammar, such as String, Choices, and GrammarBuilder objects.
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)"Make background" + colorChoice;
GrammarBuilder setPhrase =
"Set background to" + (GrammarBuilder)colorChoice;
// Create a Choices for the two alternative phrases, convert the Choices
// to a GrammarBuilder, and construct the Grammar object 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;
}
Remarks
GrammarBuilder supports conversions from the following classes.
This method accepts the objects listed above for the builder
parameter. For more information, see the Implicit operators.
The equivalent method for this operator is GrammarBuilder.Add(String, GrammarBuilder)