SemanticResultValue Oluşturucular
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
SemanticResultValue sınıfının yeni bir örneğini başlatır.
Aşırı Yüklemeler
SemanticResultValue(Object) |
Sınıfının yeni bir örneğini başlatır SemanticResultValue ve bir anlamsal değer belirtir. |
SemanticResultValue(GrammarBuilder, Object) |
Sınıfının yeni bir örneğini başlatır SemanticResultValue ve bir anlamsal değeri bir GrammarBuilder nesneyle ilişkilendirir. |
SemanticResultValue(String, Object) |
Sınıfının yeni bir örneğini başlatır SemanticResultValue ve bir anlamsal değeri bir String nesneyle ilişkilendirir. |
Açıklamalar
SemanticResultValue
Oluşturucular,,, Object veya temel alınan veri türü olan bir örnek belirtmeyi destekler bool
int
float
string
.
Bir Oluşturucu, SemanticResultValue
iki durumda bir örnek oluşturabilir:
SemanticResultValue
Örneği, oluşturmak için kullanırken bir Grammar öğesiyle birlikte açıkça ilişkilendirilmelidir GrammarBuilder Grammar .SemanticResultValue
Zaten bir dize değeri tümceciği veya bir GrammarBuilder nesneyle ilişkili.
SemanticResultValue(Object)
Sınıfının yeni bir örneğini başlatır SemanticResultValue ve bir anlamsal değer belirtir.
public:
SemanticResultValue(System::Object ^ value);
public SemanticResultValue (object value);
new System.Speech.Recognition.SemanticResultValue : obj -> System.Speech.Recognition.SemanticResultValue
Public Sub New (value As Object)
Parametreler
- value
- Object
Tarafından yönetilen değer SemanticResultValue . ,, Veya türünde bool
olmalıdır int
float
string
.
Örnekler
Aşağıdaki örnek, Grammar "set/Change/alter önalanı/background... komutunu tanıyan bir döndürür. [renk listesi] ". SemanticResultValue ve SemanticResultKey örnekleri ( Choices ve GrammarBuilder nesneleriyle birlikte), tanıma göre ayrıştırılabilen semantiğini tanımlamak için kullanılır. Ayrıştırılmış semantik, hangi rengin istendiğini ve ön planda ya da arka planın değiştirilip değiştirilmediğini tespit eder.
private Grammar FgBgColorGrammar()
{
Grammar grammar = null;
// Allow the command to begin with set, alter, change.
Choices introChoices = new Choices();
foreach (string introString in new string[] { "Change", "Set", "Alter" })
{
GrammarBuilder introGB = new GrammarBuilder(introString);
introChoices.Add(
new SemanticResultValue(introGB,
String.Format("Command: {0}", introString)));
}
GrammarBuilder cmdIntro = new GrammarBuilder(introChoices);
// Define the arguments for the command to select foreground or background
// and to change their color as semantic values.
Choices fgOrbgChoice = new Choices();
GrammarBuilder backgroundGB=new GrammarBuilder("background");
backgroundGB.Append(new SemanticResultValue(true));
fgOrbgChoice.Add(backgroundGB);
fgOrbgChoice.Add((GrammarBuilder)new SemanticResultValue("foreground", false));
SemanticResultKey fgOrbgChoiceKey = new SemanticResultKey("BgOrFgBool", fgOrbgChoice);
Choices colorChoice = new Choices();
foreach (string colorName in System.Enum.GetNames(typeof(KnownColor)))
{
// Use implicit conversion of SemanticResultValue to GrammarBuilder.
colorChoice.Add(
(GrammarBuilder) (new SemanticResultValue(colorName, (Color.FromName(colorName)).Name)));
}
// Create a GrammarBuilder for CmdArgs to be appended to CmdIntro using
// semantic keys.
GrammarBuilder cmdArgs = new GrammarBuilder();
cmdArgs.Append(new SemanticResultKey("BgOrFgBool", fgOrbgChoice));
cmdArgs.AppendWildcard();
cmdArgs.Append(new SemanticResultKey("colorStringList", colorChoice));
GrammarBuilder cmds =
GrammarBuilder.Add(
cmdIntro,
new GrammarBuilder(new SemanticResultKey("Cmd Args", cmdArgs)));
grammar = new Grammar(cmds);
grammar.Name = "Tree [Set,change,alter] [foreground,background] * color";
return grammar;
}
Açıklamalar
SemanticResultValue
Bu oluşturucunun döndürdüğü bir, belirli bir dilbilgisi öğesiyle ilişkili değil. İlişki, ile birlikte öğesinin örneği kullanılarak açık yapılmalıdır SemanticResultValue
GrammarBuilder .
Örneğin, aşağıdaki kod parçasında, Grammar Bu örnek kullanılarak oluşturulan bir GrammarBuilder "background" sözcüğünü tanırsa, true
tanınan tümcecik semantiğinin değeri ayarlanır.
GrammarBuilder backgroundGB=new GrammarBuilder("background");
backgroundGB.Append(new SemanticResultValue(true));
Şunlara uygulanır
SemanticResultValue(GrammarBuilder, Object)
Sınıfının yeni bir örneğini başlatır SemanticResultValue ve bir anlamsal değeri bir GrammarBuilder nesneyle ilişkilendirir.
public:
SemanticResultValue(System::Speech::Recognition::GrammarBuilder ^ builder, System::Object ^ value);
public SemanticResultValue (System.Speech.Recognition.GrammarBuilder builder, object value);
new System.Speech.Recognition.SemanticResultValue : System.Speech.Recognition.GrammarBuilder * obj -> System.Speech.Recognition.SemanticResultValue
Public Sub New (builder As GrammarBuilder, value As Object)
Parametreler
- builder
- GrammarBuilder
Tanımada kullanılacak bir dilbilgisi bileşeni.
- value
- Object
Tarafından yönetilen değer SemanticResultValue . ,, Veya türünde bool
olmalıdır int
float
string
.
Örnekler
Aşağıdaki örnek, Grammar "set/Change/alter önalanı/background... komutunu tanıyan bir döndürür. [renk listesi] ". SemanticResultValue ve SemanticResultKey örnekleri ( Choices ve GrammarBuilder nesneleriyle birlikte), tanıma göre ayrıştırılabilen semantiğini tanımlamak için kullanılır. Ayrıştırılmış semantik, hangi rengin istendiğini ve ön planda ya da arka planın değiştirilip değiştirilmediğini tespit eder.
private Grammar FgBgColorGrammar()
{
Grammar grammar = null;
// Allow the command to begin with set, alter, change.
Choices introChoices = new Choices();
foreach (string introString in new string[] { "Change", "Set", "Alter" })
{
GrammarBuilder introGB = new GrammarBuilder(introString);
introChoices.Add(
new SemanticResultValue(introGB,
String.Format("Command: {0}", introString)));
}
GrammarBuilder cmdIntro = new GrammarBuilder(introChoices);
// Define the arguments for the command to select foreground or background
// and to change their color as semantic values.
Choices fgOrbgChoice = new Choices();
GrammarBuilder backgroundGB=new GrammarBuilder("background");
backgroundGB.Append(new SemanticResultValue(true));
fgOrbgChoice.Add(backgroundGB);
fgOrbgChoice.Add((GrammarBuilder)new SemanticResultValue("foreground", false));
SemanticResultKey fgOrbgChoiceKey = new SemanticResultKey("BgOrFgBool", fgOrbgChoice);
Choices colorChoice = new Choices();
foreach (string colorName in System.Enum.GetNames(typeof(KnownColor)))
{
// Use implicit conversion of SemanticResultValue to GrammarBuilder.
colorChoice.Add(
(GrammarBuilder) (new SemanticResultValue(colorName, (Color.FromName(colorName)).Name)));
}
// Create a GrammarBuilder for CmdArgs to be appended to CmdIntro using
// semantic keys.
GrammarBuilder cmdArgs = new GrammarBuilder();
cmdArgs.Append(new SemanticResultKey("BgOrFgBool", fgOrbgChoice));
cmdArgs.AppendWildcard();
cmdArgs.Append(new SemanticResultKey("colorStringList", colorChoice));
GrammarBuilder cmds =
GrammarBuilder.Add(
cmdIntro,
new GrammarBuilder(new SemanticResultKey("Cmd Args", cmdArgs)));
grammar = new Grammar(cmds);
grammar.Name = "Tree [Set,change,alter] [foreground,background] * color";
return grammar;
}
Açıklamalar
Tarafından belirtilen dilbilgisi öğesi GrammarBuilder tanıma mantığındaki kullanılıyorsa, value
tanınan çıkışın semantiğinin ayarlanması gerekir.
Aşağıdaki kod parçasında, örnekle oluşturulan tanıma mantığı GrammarBuilder ( myGb
) Choices myChoice
girişi tanımlamak için nesnesini () kullanıyorsa, değer true
tanınan semantiğe eklenir.
myGb.Append(new SemanticResultValue(myChoice, true);
GrammarBuilder, Ve için örtük dönüştürmeyi destekler, Choices SemanticResultValue
ve SemanticResultKey Bu Oluşturucu bu nesneleri de kullanabilir.
Şunlara uygulanır
SemanticResultValue(String, Object)
Sınıfının yeni bir örneğini başlatır SemanticResultValue ve bir anlamsal değeri bir String nesneyle ilişkilendirir.
public:
SemanticResultValue(System::String ^ phrase, System::Object ^ value);
public SemanticResultValue (string phrase, object value);
new System.Speech.Recognition.SemanticResultValue : string * obj -> System.Speech.Recognition.SemanticResultValue
Public Sub New (phrase As String, value As Object)
Parametreler
- phrase
- String
Tanımada kullanılacak bir ifade.
- value
- Object
Tarafından yönetilen değer SemanticResultValue . ,, Veya türünde bool
olmalıdır int
float
string
.
Örnekler
Aşağıdaki örnek, Grammar "set/Change/alter önalanı/background... komutunu tanıyan bir döndürür. [renk listesi] ". SemanticResultValue ve SemanticResultKey örnekleri ( Choices ve GrammarBuilder nesneleriyle birlikte), tanıma göre ayrıştırılabilen semantiğini tanımlamak için kullanılır. Ayrıştırılmış semantik, hangi rengin istendiğini ve ön planda ya da arka planın değiştirilip değiştirilmediğini tespit eder.
private Grammar FgBgColorGrammar()
{
Grammar grammar = null;
// Allow command to begin with set, alter, change.
Choices introChoices = new Choices();
foreach (string introString in new string[] { "Change", "Set", "Alter" })
{
GrammarBuilder introGB = new GrammarBuilder(introString);
introChoices.Add(
new SemanticResultValue(introGB,
String.Format("Command: {0}", introString)));
}
GrammarBuilder cmdIntro = new GrammarBuilder(introChoices);
// Define the arguments for the command to select foreground or background
// and to change their color as semantic values.
Choices fgOrbgChoice = new Choices();
GrammarBuilder backgroundGB=new GrammarBuilder("background");
backgroundGB.Append(new SemanticResultValue(true));
fgOrbgChoice.Add(backgroundGB);
fgOrbgChoice.Add((GrammarBuilder)new SemanticResultValue("foreground", false));
SemanticResultKey fgOrbgChoiceKey = new SemanticResultKey("BgOrFgBool", fgOrbgChoice);
Choices colorChoice = new Choices();
foreach (string colorName in System.Enum.GetNames(typeof(KnownColor)))
{
// Use implicit conversion of SemanticResultValue to GrammarBuilder.
colorChoice.Add(
(GrammarBuilder) (new SemanticResultValue(colorName, (Color.FromName(colorName)).Name)));
}
// Create a GrammarBuilder for CmdArgs to be appended to CmdIntro using
// semantic keys.
GrammarBuilder cmdArgs = new GrammarBuilder();
cmdArgs.Append(new SemanticResultKey("BgOrFgBool", fgOrbgChoice));
cmdArgs.AppendWildcard();
cmdArgs.Append(new SemanticResultKey("colorStringList", colorChoice));
GrammarBuilder cmds =
GrammarBuilder.Add(cmdIntro,
new GrammarBuilder(new SemanticResultKey("Cmd Args", cmdArgs)));
grammar = new Grammar(cmds);
grammar.Name = "Tree [Set,change,alter] [foreground,background] * color";
return grammar;
}
Açıklamalar
Tarafından belirtilen dize phrase
tanıma mantığındaki kullanılıyorsa, value
tanınan çıkışın semantiğine ayarlanır.
Aşağıdaki kod parçasında, örnekle oluşturulan tanıma mantığı, GrammarBuilder myGb
girişi tanımlamak için "ipotek" dizesini kullanıyorsa, değer true
tanınan semantiğe eklenecektir.
myGb.Append(new SemanticResultValue("my mortgage", true);