GrammarBuilder 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
GrammarBuilder 클래스의 새 인스턴스를 초기화합니다.
오버로드
| Name | Description |
|---|---|
| GrammarBuilder() |
클래스의 빈 새 인스턴스를 초기화합니다 GrammarBuilder . |
| GrammarBuilder(Choices) |
대안 집합에서 클래스의 GrammarBuilder 새 인스턴스를 초기화합니다. |
| GrammarBuilder(SemanticResultKey) |
의미 체계 키에서 클래스의 GrammarBuilder 새 인스턴스를 초기화합니다. |
| GrammarBuilder(SemanticResultValue) |
의미 체계 값에서 클래스의 GrammarBuilder 새 인스턴스를 초기화합니다. |
| GrammarBuilder(String) |
단어 시퀀스에서 클래스의 GrammarBuilder 새 인스턴스를 초기화합니다. |
| GrammarBuilder(String, SubsetMatchingMode) |
단어 시퀀스의 하위 집합에 GrammarBuilder 대한 클래스의 새 인스턴스를 초기화합니다. |
| GrammarBuilder(GrammarBuilder, Int32, Int32) |
반복된 요소에서 클래스의 GrammarBuilder 새 인스턴스를 초기화합니다. |
| GrammarBuilder(String, Int32, Int32) |
a의 단어 시퀀스에서 클래스의 GrammarBuilder 새 인스턴스를 String 초기화하고 반복할 수 있는 횟수를 String 지정합니다. |
설명
이 클래스의 인스턴스는 다른 클래스에서 암시적으로 변환하거나 개체를 두 번째 개체와 결합하여 GrammarBuilder 새 GrammarBuilder개체에서 새 개체로 가져올 수도 있습니다. 자세한 내용은 및 Addition 메서드를 Implicit 참조하세요.
기존 GrammarBuilder제약 조건에 제약 조건을 추가하려면 , , AppendAppendDictation, AppendRuleReference메서드 및 AppendWildcard 연산자를 Addition 사용합니다Add.
중요합니다
음성 인식기 동일한 키 이름 또는 동일한 의미 체계 요소의 값을 반복적으로 수정할 수 있는 여러 의미 체계 요소를 사용 하 여 중복 된 의미 체계 요소를 포함 하는 음성 인식 문법을 사용 하는 경우 예외를 throw할 수 있습니다.
음성 인식 문법을 빌드하고 사용하는 방법에 대한 자세한 내용은 음성 인식을 참조하세요.
GrammarBuilder()
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
클래스의 빈 새 인스턴스를 초기화합니다 GrammarBuilder .
public:
GrammarBuilder();
public GrammarBuilder();
Public Sub New ()
예제
다음 예제에서는 "배경 colorChoice 만들기" 또는 "background를 colorChoice로 설정"이라는 두 구 중 하나를 인식할 수 있는 문법을 생성하기 위해 사용 및 Choices 개체를 사용합니다GrammarBuilder.
이 예제에서는 개체를 Choices 사용하여 개체 배열 String 에서 colorChoice에 허용되는 값 목록을 만듭니다.
Choices 개체는 SRGS 사양의 one-of 요소와 유사하며, 다른 구 집합을 포함하며, 이 중 하나를 말할 때 인식할 수 있습니다. 또한 이 예제에서는 개체를 Choices 사용하여 두 GrammarBuilder 개체의 배열을 결과 문법에서 인식할 수 있는 대체 구 쌍으로 그룹화합니다. 대체 단어 또는 구는 대부분의 문법의 구성 요소이며 Choices 개체는 로 구성된 GrammarBuilder문법에 대해 이 기능을 제공합니다.
이 예제에서는 마지막으로 개체에서 GrammarBuilder 생성된 개체를 Choices 만듭니다Grammar.
private Grammar CreateColorGrammar()
{
// Create a set of color choices.
Choices colorChoice = new Choices(new string[] {"red", "green", "blue"});
GrammarBuilder colorElement = new GrammarBuilder(colorChoice);
// Create grammar builders for the two versions of the phrase.
GrammarBuilder makePhrase = new GrammarBuilder("Make background");
makePhrase.Append(colorElement);
GrammarBuilder setPhrase = new GrammarBuilder("Set background to");
setPhrase.Append(colorElement);
// Create a Choices for the two alternative phrases, convert the Choices
// to a GrammarBuilder, and construct the Grammar object from the result.
GrammarBuilder bothPhrases = new GrammarBuilder();
Choices bothChoices = new Choices(new GrammarBuilder[] {makePhrase, setPhrase});
bothPhrases.Append(bothChoices);
Grammar grammar = new Grammar(bothPhrases);
grammar.Name = "backgroundColor";
return grammar;
}
설명
기존 GrammarBuilder 개체에 규칙을 추가하려면 , Append, AppendDictation, AppendRuleReference메서드 및 AppendWildcard 연산자를 Addition 사용합니다Add.
중요합니다
음성 인식기 동일한 키 이름 또는 동일한 의미 체계 요소의 값을 반복적으로 수정할 수 있는 여러 의미 체계 요소를 사용 하 여 중복 된 의미 체계 요소를 포함 하는 음성 인식 문법을 사용 하는 경우 예외를 throw할 수 있습니다.
추가 정보
적용 대상
GrammarBuilder(Choices)
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
대안 집합에서 클래스의 GrammarBuilder 새 인스턴스를 초기화합니다.
public:
GrammarBuilder(System::Speech::Recognition::Choices ^ alternateChoices);
public GrammarBuilder(System.Speech.Recognition.Choices alternateChoices);
new System.Speech.Recognition.GrammarBuilder : System.Speech.Recognition.Choices -> System.Speech.Recognition.GrammarBuilder
Public Sub New (alternateChoices As Choices)
매개 변수
- alternateChoices
- Choices
대안 집합입니다.
예제
다음 예제에서는 "배경 colorChoice 만들기" 또는 "background를 colorChoice로 설정"이라는 두 구 중 하나를 인식할 수 있는 문법을 생성하기 위해 사용 및 Choices 개체를 사용합니다GrammarBuilder.
이 예제에서는 개체를 Choices 사용하여 개체 배열 String 에서 colorChoice에 허용되는 값 목록을 만듭니다.
Choices 개체는 SRGS 사양의 one-of 요소와 유사하며, 일련의 대체 구를 포함하며, 이 중 하나는 말할 때 인식할 수 있습니다. 또한 이 예제에서는 개체를 Choices 사용하여 두 GrammarBuilder 개체의 배열을 결과 문법에서 인식할 수 있는 대체 구 쌍으로 그룹화합니다. 대체 단어 또는 구는 대부분의 문법의 구성 요소이며 Choices 개체는 로 구성된 GrammarBuilder문법에 대해 이 기능을 제공합니다.
이 예제에서는 마지막으로 개체에서 GrammarBuilder 생성된 개체를 Choices 만듭니다Grammar.
private Grammar CreateColorGrammar()
{
// Create a set of color choices.
Choices colorChoice = new Choices(new string[] {"red", "green", "blue"});
GrammarBuilder colorElement = new GrammarBuilder(colorChoice);
// Create grammar builders for the two versions of the phrase.
GrammarBuilder makePhrase = new GrammarBuilder("Make background");
makePhrase.Append(colorElement);
GrammarBuilder setPhrase = new GrammarBuilder("Set background to");
setPhrase.Append(colorElement);
// 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});
Grammar grammar = new Grammar((GrammarBuilder)bothChoices);
grammar.Name = "backgroundColor";
return grammar;
}
설명
대안이 포함된 음성 인식 문법을 빌드하는 방법에 대한 자세한 내용은 선택 항목을 사용하여 GrammarBuilder 문법 만들기를 참조하세요.
추가 정보
적용 대상
GrammarBuilder(SemanticResultKey)
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
의미 체계 키에서 클래스의 GrammarBuilder 새 인스턴스를 초기화합니다.
public:
GrammarBuilder(System::Speech::Recognition::SemanticResultKey ^ key);
public GrammarBuilder(System.Speech.Recognition.SemanticResultKey key);
new System.Speech.Recognition.GrammarBuilder : System.Speech.Recognition.SemanticResultKey -> System.Speech.Recognition.GrammarBuilder
Public Sub New (key As SemanticResultKey)
매개 변수
의미 체계 키입니다.
예제
다음 예제에서는 색 집합에서 colorChoice를 선택하는 두 구인 "배경색을 설정"과 "colorChoice로 배경 설정"을 인식할 수 있는 음성 인식 문법을 만듭니다. 문법을 사용하면 사용자가 여러 색 이름을 말할 수 있으며 인식된 색 이름에 대한 의미 체계 정보를 애플리케이션에 반환합니다.
이 예제에서는 사용자가 말한 색과 연결된 항목을 검색 SemanticValue 할 수 있는 단일 SemanticResultKey 항목을 사용합니다. 예를 들어 입력에 "배경을 빨간색으로 설정"이라는 구가 포함된 경우 인식 결과에는 이벤트에 대한 처리기를 사용하여 검색할 수 있는 "#FF0000"의 의미 체계 값이 SpeechRecognized 포함됩니다.
이 예제에서는 , Choices, SemanticResultKeySemanticResultValue및 GrammarBuilder 개체를 사용하여 String마지막 GrammarBuilder 개체bothPhrases에 모두 포함된 제약 조건을 빌드합니다. 마지막으로, 이 예제는 완료GrammarBuilder된 Grammar 개체에서 개체를 생성합니다.
private Grammar CreateColorGrammar()
{
// Create a set of color choices.
// Include semantic information about each of the colors.
Choices colorChoice = new Choices();
GrammarBuilder colorBuilder = new GrammarBuilder("red");
SemanticResultValue colorValue =
new SemanticResultValue(colorBuilder, "#FF0000");
colorChoice.Add(new GrammarBuilder(colorValue));
colorBuilder = new GrammarBuilder("green");
colorValue = new SemanticResultValue(colorBuilder, "#00FF00");
colorChoice.Add(new GrammarBuilder(colorValue));
colorBuilder = new GrammarBuilder("blue");
colorValue = new SemanticResultValue(colorBuilder, "#0000FF");
colorChoice.Add(new GrammarBuilder(colorValue));
GrammarBuilder colorElement = new GrammarBuilder(colorChoice);
// Create grammar builders for the two versions of the phrase.
GrammarBuilder makePhrase = new GrammarBuilder("Make background");
makePhrase.Append(colorElement);
GrammarBuilder setPhrase = new GrammarBuilder("Set background to");
setPhrase.Append(colorElement);
// Create a Choices object for the two alternative phrases.
Choices bothChoices = new Choices(new GrammarBuilder[] {makePhrase, setPhrase});
GrammarBuilder bothPhrases = new GrammarBuilder(bothChoices);
// Create the semantic key for referencing the color information.
SemanticResultKey colorKey =
new SemanticResultKey("ColorCode", bothPhrases);
bothPhrases = new GrammarBuilder(colorKey);
// Construct the Grammar object from the GrammarBuilder.
Grammar grammar = new Grammar(bothPhrases);
grammar.Name = "backgroundColor";
return grammar;
}
설명
개체에서 인스턴스를 GrammarBuilderSemanticResultValue 만들 때 인식 결과에 반환될 수 있는 의미 체계 정보를 문법에 추가합니다. 이벤트 처리기
중요합니다
개체 또는 SemanticResultKey 인스턴스를 생성하는 GrammarBuilderSemanticResultValue 경우 동일한 키 이름 또는 개체의 속성을 SemanticValue 반복적으로 수정 Value 할 수 있는 여러 의미 체계 요소를 사용하여 중복 의미 체계 요소를 만들지 않도록 해야 합니다. 이러한 상황이 발생하면 음성 인식기가 예외를 throw할 수 있습니다.
추가 정보
적용 대상
GrammarBuilder(SemanticResultValue)
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
의미 체계 값에서 클래스의 GrammarBuilder 새 인스턴스를 초기화합니다.
public:
GrammarBuilder(System::Speech::Recognition::SemanticResultValue ^ value);
public GrammarBuilder(System.Speech.Recognition.SemanticResultValue value);
new System.Speech.Recognition.GrammarBuilder : System.Speech.Recognition.SemanticResultValue -> System.Speech.Recognition.GrammarBuilder
Public Sub New (value As SemanticResultValue)
매개 변수
- value
- SemanticResultValue
의미 체계 값 또는 이름/값 쌍입니다.
예제
다음 예제에서는 색 집합에서 colorChoice를 선택하는 두 구인 "배경색을 설정"과 "colorChoice로 배경 설정"을 인식할 수 있는 음성 인식 문법을 만듭니다. 문법을 사용하면 사용자가 여러 색 이름을 말할 수 있으며 인식된 색 이름에 대한 의미 체계 정보를 애플리케이션에 반환합니다.
이 예제에서는 사용자가 말한 색과 연결된 항목을 검색 SemanticValue 할 수 있는 단일 SemanticResultKey 항목을 사용합니다. 예를 들어 입력에 "배경을 빨간색으로 설정"이라는 구가 포함된 경우 인식 결과에는 이벤트에 대한 처리기를 사용하여 검색할 수 있는 "#FF0000"의 의미 체계 값이 SpeechRecognized 포함됩니다.
이 예제에서는 , Choices, SemanticResultKeySemanticResultValue및 GrammarBuilder 개체를 사용하여 String마지막 GrammarBuilder 개체bothPhrases에 모두 포함된 제약 조건을 빌드합니다. 마지막으로, 이 예제는 완료GrammarBuilder된 Grammar 개체에서 개체를 생성합니다.
private Grammar CreateColorGrammar()
{
// Create a set of color choices.
// Include semantic information about each of the colors.
Choices colorChoice = new Choices();
GrammarBuilder colorBuilder = new GrammarBuilder("red");
SemanticResultValue colorValue =
new SemanticResultValue(colorBuilder, "#FF0000");
colorChoice.Add(new GrammarBuilder(colorValue));
colorBuilder = new GrammarBuilder("green");
colorValue = new SemanticResultValue(colorBuilder, "#00FF00");
colorChoice.Add(new GrammarBuilder(colorValue));
colorBuilder = new GrammarBuilder("blue");
colorValue = new SemanticResultValue(colorBuilder, "#0000FF");
colorChoice.Add(new GrammarBuilder(colorValue));
GrammarBuilder colorElement = new GrammarBuilder(colorChoice);
// Create grammar builders for the two versions of the phrase.
GrammarBuilder makePhrase = new GrammarBuilder("Make background");
makePhrase.Append(colorElement);
GrammarBuilder setPhrase = new GrammarBuilder("Set background to");
setPhrase.Append(colorElement);
// Create a Choices for the two alternative phrases.
Choices bothChoices = new Choices(new GrammarBuilder[] {makePhrase, setPhrase});
GrammarBuilder bothPhrases = new GrammarBuilder(bothChoices);
// Create the semantic key for referencing the color information.
SemanticResultKey colorKey =
new SemanticResultKey("ColorCode", bothPhrases);
bothPhrases = new GrammarBuilder(colorKey);
// Construct the grammar from the grammar builder.
Grammar grammar = new Grammar(bothPhrases);
grammar.Name = "backgroundColor";
return grammar;
}
설명
개체에서 인스턴스를 GrammarBuilderSemanticResultValue 만들 때 인식 결과에 반환될 수 있는 의미 체계 정보를 문법에 추가합니다. 이벤트 처리기
중요합니다
개체 또는 SemanticResultKey 인스턴스를 생성하는 GrammarBuilderSemanticResultValue 경우 동일한 키 이름 또는 개체의 속성을 SemanticValue 반복적으로 수정 Value 할 수 있는 여러 의미 체계 요소를 사용하여 중복 의미 체계 요소를 만들지 않도록 해야 합니다. 이러한 상황이 발생하면 음성 인식기가 예외를 throw할 수 있습니다.
추가 정보
적용 대상
GrammarBuilder(String)
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
단어 시퀀스에서 클래스의 GrammarBuilder 새 인스턴스를 초기화합니다.
public:
GrammarBuilder(System::String ^ phrase);
public GrammarBuilder(string phrase);
new System.Speech.Recognition.GrammarBuilder : string -> System.Speech.Recognition.GrammarBuilder
Public Sub New (phrase As String)
매개 변수
- phrase
- String
단어의 시퀀스입니다.
예제
다음 예제에서는 "배경 colorChoice 만들기" 또는 "background를 colorChoice로 설정"이라는 두 구 중 하나를 인식할 수 있는 문법을 생성하기 위해 사용 및 Choices 개체를 사용합니다GrammarBuilder.
개체를 사용하여 ChoicescolorChoice에 허용되는 값 목록을 만든 후 이 예제에서는 두 GrammarBuilder 개체 makePhrase 를 초기화하고 setPhrase문자열을 인수로 사용합니다.
이 예제에서는 마지막으로 개체에서 Grammar 개체로 캐스팅된 Choices 개체를 GrammarBuilder 만듭니다.
private Grammar CreateColorGrammar()
{
// Create a set of color choices.
Choices colorChoice = new Choices(new string[] {"red", "green", "blue"});
GrammarBuilder colorElement = new GrammarBuilder(colorChoice);
// Create grammar builders for the two versions of the phrase.
GrammarBuilder makePhrase = new GrammarBuilder("Make background");
makePhrase.Append(colorElement);
GrammarBuilder setPhrase = new GrammarBuilder("Set background to");
setPhrase.Append(colorElement);
// 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});
Grammar grammar = new Grammar((GrammarBuilder)bothChoices);
grammar.Name = "backgroundColor";
return grammar;
}
설명
이 구는 음성 인식 문법에서 인식할 수 있는 정확한 음성 구를 나타냅니다. 문자열을 포함하는 음성 인식 문법을 빌드하는 방법에 대한 자세한 내용은 문자열을 사용하여 GrammarBuilder 문법 만들기를 참조하세요.
추가 정보
적용 대상
GrammarBuilder(String, SubsetMatchingMode)
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
단어 시퀀스의 하위 집합에 GrammarBuilder 대한 클래스의 새 인스턴스를 초기화합니다.
public:
GrammarBuilder(System::String ^ phrase, System::Speech::Recognition::SubsetMatchingMode subsetMatchingCriteria);
public GrammarBuilder(string phrase, System.Speech.Recognition.SubsetMatchingMode subsetMatchingCriteria);
new System.Speech.Recognition.GrammarBuilder : string * System.Speech.Recognition.SubsetMatchingMode -> System.Speech.Recognition.GrammarBuilder
Public Sub New (phrase As String, subsetMatchingCriteria As SubsetMatchingMode)
매개 변수
- phrase
- String
단어의 시퀀스입니다.
- subsetMatchingCriteria
- SubsetMatchingMode
음성 인식 문법이 구를 인식하는 데 사용하는 일치 모드입니다.
예제
다음 예제에서는 각 SubsetMatchingMode 값에 대한 음성 인식 문법과 일치하는 모드 문법 중에서 선택하기 위한 문법을 만듭니다. 값 phrase 이 "one two three four five six seven"이면 하위 시퀀스 문법은 입력 "2 3 4"를 인식하지만 입력 "1 3 5"는 인식하지 않습니다. 그러나 순서가 지정된 하위 집합 문법은 이러한 두 입력을 모두 인식합니다.
private static IEnumerable<Grammar>
CreateMatchingModeGrammars(string phrase)
{
List<Grammar> grammars = new List<Grammar>(5);
Choices modeChoice = new Choices();
Type enumType = typeof(SubsetMatchingMode);
foreach (SubsetMatchingMode mode in Enum.GetValues(enumType))
{
string modeName = Enum.GetName(enumType, mode);
modeName = BreakAtCaps(modeName);
GrammarBuilder builder = new GrammarBuilder(phrase, mode);
Grammar modeGrammar = new Grammar(builder);
modeGrammar.Name = modeName;
modeGrammar.Enabled = false;
grammars.Add(modeGrammar);
modeChoice.Add(modeName);
}
Grammar choiceGrammar = new Grammar(modeChoice);
choiceGrammar.Name = "choice";
grammars.Add(choiceGrammar);
return grammars;
}
// Insert spaces preceding each uppercase letter in a string.
private static string BreakAtCaps(string item)
{
if (item == null || item.Length == 0)
{
return item;
}
StringBuilder sb = new StringBuilder(item[0].ToString());
for (int i = 1; i < item.Length; i++)
{
char c = item[i];
if (char.IsUpper(c))
{
sb.Append(" ");
}
sb.Append(c);
}
return sb.ToString();
}
설명
매개 변수는 phrase 음성 인식 문법에서 인식할 수 있는 구를 나타냅니다. 매개 변수는 subsetMatchingMode 전체 구를 성공적으로 인식하기 위해 말할 수 있는 구의 하위 집합을 지정합니다. 사용자가 항목과 일치하도록 전체 이름을 말할 필요 없이 긴 이름을 가진 항목 목록이 있는 문법을 만드는 데 사용할 수 있습니다.
일치 모드에 대한 자세한 내용은 다음을 참조하세요 SubsetMatchingMode. 문자열을 포함하는 음성 인식 문법을 빌드하는 방법에 대한 자세한 내용은 문자열을 사용하여 GrammarBuilder 문법 만들기를 참조하세요.
추가 정보
적용 대상
GrammarBuilder(GrammarBuilder, Int32, Int32)
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
반복된 요소에서 클래스의 GrammarBuilder 새 인스턴스를 초기화합니다.
public:
GrammarBuilder(System::Speech::Recognition::GrammarBuilder ^ builder, int minRepeat, int maxRepeat);
public GrammarBuilder(System.Speech.Recognition.GrammarBuilder builder, int minRepeat, int maxRepeat);
new System.Speech.Recognition.GrammarBuilder : System.Speech.Recognition.GrammarBuilder * int * int -> System.Speech.Recognition.GrammarBuilder
Public Sub New (builder As GrammarBuilder, minRepeat As Integer, maxRepeat As Integer)
매개 변수
- builder
- GrammarBuilder
반복된 요소입니다.
- minRepeat
- Int32
일치 항목을 구성하기 위해 정의된 builder 요소와 일치하는 입력이 발생해야 하는 최소 횟수입니다.
- maxRepeat
- Int32
정의된 builder 요소와 일치하는 입력이 일치를 구성하기 위해 발생할 수 있는 최대 횟수입니다.
예제
다음 예제에서는 피자를 주문하기 위한 음성 인식 문법을 만듭니다. 선택적 여는 구로 시작하여 1~4개의 토핑으로 시작하고 "pizza"라는 단어로 닫힙니다.
private static Grammar CreatePizzaGrammar()
{
// Create a Choices object from a string array of alternative toppings.
Choices toppings = new Choices(new string[] {
"cheese", "mushroom", "tomato", "onion",
"anchovy", "chicken", "pepperoni"});
// Create a GrammarBuilder and append the Choices object.
GrammarBuilder andToppings = new GrammarBuilder("and", 0, 1);
andToppings.Append(toppings);
// Construct the phrase.
GrammarBuilder gb = new GrammarBuilder("I would like a", 0, 1);
gb.Append(toppings);
gb.Append(new GrammarBuilder(andToppings, 0, 3));
gb.Append("pizza");
// Create the Grammar from the GrammarBuilder.
Grammar grammar = new Grammar(gb);
grammar.Name = "Pizza Order";
return grammar;
}
설명
값이 0이면 새 GrammarBuilder 값 minRepeat 이 선택적 요소를 나타냅니다.
값 minRepeat 은 0보다 크거나 같아야 하며 값보다 작거나 같 maxRepeat아야 합니다.
중요합니다
개체 또는 SemanticResultKey 인스턴스를 포함하는 SemanticResultValue 개체에 대해 GrammarBuilder 반복을 지정하는 경우 동일한 키 이름 또는 개체의 속성을 SemanticValue 반복적으로 수정 Value 할 수 있는 여러 의미 체계 요소를 사용하여 중복 의미 체계 요소를 만들지 않도록 해야 합니다. 이러한 상황이 발생하면 음성 인식기가 예외를 throw할 수 있습니다.
추가 정보
적용 대상
GrammarBuilder(String, Int32, Int32)
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
- Source:
- GrammarBuilder.cs
a의 단어 시퀀스에서 클래스의 GrammarBuilder 새 인스턴스를 String 초기화하고 반복할 수 있는 횟수를 String 지정합니다.
public:
GrammarBuilder(System::String ^ phrase, int minRepeat, int maxRepeat);
public GrammarBuilder(string phrase, int minRepeat, int maxRepeat);
new System.Speech.Recognition.GrammarBuilder : string * int * int -> System.Speech.Recognition.GrammarBuilder
Public Sub New (phrase As String, minRepeat As Integer, maxRepeat As Integer)
매개 변수
- phrase
- String
반복되는 단어 시퀀스입니다.
- minRepeat
- Int32
구와 일치하는 입력이 일치를 구성하기 위해 발생해야 하는 최소 횟수입니다.
- maxRepeat
- Int32
구와 일치하는 입력이 일치를 구성하기 위해 발생할 수 있는 최대 횟수입니다.
예제
다음 예제에서는 피자를 주문하기 위한 음성 인식 문법을 만듭니다. 선택적 여는 구로 시작하여 1~4개의 토핑으로 시작하고 "pizza"라는 단어로 닫힙니다.
private static Grammar CreatePizzaGrammar()
{
// Create a Choices object with alternatives for toppings.
Choices toppings = new Choices(new string[] {
"cheese", "mushroom", "tomato", "onion",
"anchovy", "chicken", "pepperoni"});
// Create a GrammarBuilder and append the Choices object.
GrammarBuilder andToppings = new GrammarBuilder("and", 0, 1);
andToppings.Append(toppings);
// Construct the phrase.
GrammarBuilder gb = new GrammarBuilder("I would like a", 0, 1);
gb.Append(toppings);
gb.Append(new GrammarBuilder(andToppings, 0, 3));
gb.Append("pizza");
// Create the Grammar from the GrammarBuilder.
Grammar grammar = new Grammar(gb);
grammar.Name = "Pizza Order";
return grammar;
}
설명
값이 0이면 새 GrammarBuilder 값 minRepeat 이 선택적 요소를 나타냅니다.
값 minRepeat 은 0보다 크거나 같아야 하며 값보다 작거나 같 maxRepeat아야 합니다. 문자열을 포함하는 음성 인식 문법을 빌드하는 방법에 대한 자세한 내용은 문자열을 사용하여 GrammarBuilder 문법 만들기를 참조하세요.