GrammarBuilder.Append Method (String, SubsetMatchingMode)


Appends an element for a subset of a phrase to the current sequence of grammar elements.

Namespace:   System.Speech.Recognition
Assembly:  System.Speech (in System.Speech.dll)

public void Append(
	string phrase,
	SubsetMatchingMode subsetMatchingCriteria


Type: System.String

The sequence of words to append.

Type: System.Speech.Recognition.SubsetMatchingMode

The matching mode the grammar uses to recognize the phrase.

The subset element is added to the end of the current sequence of elements. For more information about building a speech recognition grammar using strings, see Using Strings to Create a GrammarBuilder Grammar.

For detailed information on the use of subset matching modes, see System.Speech.Recognition.SubsetMatchingMode.

The following example creates a speech recognition grammar for each SubsetMatchingMode value. For example, the generated grammar OrderedSubset recognizes the phrases, "three four five" and "one three five", and the grammar Subsequence recognizes the phrase "three four five", but not the phrase, "one three five".

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

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

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

  return grammars.ToArray();

.NET Framework
Available since 3.0
Return to top