Bagikan melalui


SubsetMatchingMode Enum

Definition

Enumerates values of subset matching mode.

public enum class SubsetMatchingMode
public enum SubsetMatchingMode
type SubsetMatchingMode = 
Public Enum SubsetMatchingMode
Inheritance
SubsetMatchingMode

Fields

Name Value Description
Subsequence 0

Indicates that subset matching mode is Subsequence.

OrderedSubset 1

Indicates that subset matching mode is OrderedSubset.

SubsequenceContentRequired 2

Indicates that subset matching mode is SubsequenceContentRequired.

OrderedSubsetContentRequired 3

Indicates that subset matching mode is OrderedSubsetContentRequired.

Examples

Below is a test routine which generates four Grammar objects, using the same phrase, for each of the SubsetMatchingModes. These Grammar objects can then be tested.

private void CreateSubsetMatchTest()   
{  
  foreach ( System.Speech.Recognition.SubsetMatchingMode mode   
              in Enum.GetValues(typeof(System.Speech.Recognition.SubsetMatchingMode)))  
  {  
    GrammarBuilder gb = new GrammarBuilder("a car the truck a boat that plane",mode);  
    Grammar grammar = new Grammar(gb);  
    grammar.Name = mode.ToString();  
    grammar.Enabled=true;  
    _recognizer.LoadGrammar(grammar);  
  }  
}  

Remarks

In System.Speech, you can construct a grammar that successfully recognizes a phrase even though only a subset of its contents is found in the audio input.

By default, a recognition engine requires an exact match against an entire phrase. The recognition engine can also match partial phrases according to parameters defined by a SubsetMatchingMode member used as an argument to the GrammarBuilder or SrgsSubset constructors, or the Append method.

The following illustrates how each of the SubsetMatchingMode members affects recognition when used in a grammar that contains the phrase "a car the truck a boat that plane".

OrderedSubset

This mode indicates that a subset of the phrase will be used to successfully recognize the entire phrase if the following are true:

  • One or more words in the phrase are recognized in the audio input.

  • The relative order of those recognized words is the same as in the phrase.

  • Matched words may consist of only prepositions and articles.

Adding the phrase "a car the truck a boat that plane" to a grammar using OrderedSubset mode produces the following result on recognition:

Input Phrase Result
"a car the truck a boat that plane" The entire phrase "a car the truck a boat that plane" is recognized.
"a car the truck a boat" The entire phrase "a car the truck a boat that plane" is recognized.
"a car the that plane" The entire phrase "a car the truck a boat that plane" is recognized. A recognized subset is not required to be a sequence of the original string.
"a car the boat a truck that plane" Recognition is not successful. The words are out of order.
"a the" The entire phrase "a car the truck a boat that plane" is recognized. Prepositions and articles are used for recognition.

OrderedSubsetContentRequired

This mode indicates that a subset of the phrase will be used to successfully recognize the entire phrase if the following are true:

  • One or more words in the phrase are recognized in the audio input, and

  • The relative order of those recognized words is the same as in the phrase.

  • Matched words cannot consist of only prepositions and articles.

Adding the phrase "a car the truck a boat that plane" to a grammar using OrderedSubsetContentRequired mode produces the following result on recognition:

Input Phrase Result
"a car the truck a boat that plane" The entire phrase "a car the truck a boat that plane" is recognized.
"a car the truck a boat" The entire phrase "a car the truck a boat that plane" is recognized.
"a car the that plane" The entire phrase "a car the truck a boat that plane" is recognized. A recognized subset is not required to be a sequence of the original string.
"a car the boat a truck that plane" Recognition is not successful. The words are out of order.
"a the" Recognition is not successful. Speech input must contain words other than articles and prepositions.

Subsequence:

This mode indicates that a subset of the phrase will be used to successfully recognize the entire phrase if the following are true:

  • One or more words in the phrase are recognized in the audio input as a sequence of the phrase, and

  • The relative order of those recognized words is the same as in the phrase.

  • Matched words may consist of only prepositions and articles.

Adding the phrase "a car the truck a boat that plane" to a grammar using Subsequence mode produces the following result on recognition:

Input Phrase Result
"a car the truck a boat that plane" The entire phrase "a car the truck a boat that plane" is recognized.
"a car the truck a boat" The entire phrase "a car the truck a boat that plane" is recognized.
"a car the that plane" Recognition is not successful. A recognized subset is required to be a sequence of the original string.
"a car the boat a truck that plane" Recognition is not successful. The words are out of order.
"a the" The entire phrase "a car the truck a boat that plane" is recognized. Prepositions and articles are used for recognition.

SubsequenceContentRequired

This mode indicates that a subset of the phrase will be used to successfully recognize the entire phrase if the following are true:

  • One or more words in the match string are recognized in the audio input as a sequence of the phrase.

  • Matched words cannot consist of only prepositions and articles.

Adding the phrase "a car the truck a boat that plane" to a grammar using SubsequenceContentRequired mode produces the following result on recognition:

Input Phrase Result
"a car the truck a boat that plane" The entire phrase "a car the truck a boat that plane" is recognized.
"a car the truck a boat" The entire phrase "a car the truck a boat that plane" is recognized.
"a car the that plane" Recognition is not successful. A recognized subset is required to be a sequence of the original string.
"a car the boat a truck that plane" Recognition is not successful. The words are out of order.
"a the" Recognition is not successful. Speech input must contain words other than articles and prepositions.

Applies to

See also