Skip to content

Commit e23d7f8

Browse files
authored
add language slugs (#11221)
1 parent 3774ce2 commit e23d7f8

File tree

16 files changed

+55
-170
lines changed

16 files changed

+55
-170
lines changed

xml/System.Speech.Recognition.SrgsGrammar/SrgsDocument.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ Console.WriteLine("Root Rule " + bookFlight.Root.Id);
253253
Grammar g = new Grammar(bookFlight);
254254
g.Name = ("City Chooser");
255255
recognizer.LoadGrammarAsync(g);
256-
257256
```
258257
259258
]]></format>

xml/System.Speech.Recognition.SrgsGrammar/SrgsOneOf.xml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,9 @@
8989
## Examples
9090
The following example uses the <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> element to build lists of <xref:System.Speech.Recognition.SrgsGrammar.SrgsItem> elements containing country/region names, any one of which may be used to recognize the containing phrase. The example then adds one of the resulting <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> objects to their respective rules for European and South American countries/regions. Further on, the example uses the <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> object to group rule references to `ruleEurope` and `ruleSAmerica` into a list of two alternatives, either one of which may be used to recognize spoken input.
9191
92-
```
92+
```csharp
9393
public void WorldSoccerWinners ()
9494
{
95-
9695
// Create an SrgsDocument, create a new rule
9796
// and set its scope to public.
9897
SrgsDocument document = new SrgsDocument();
@@ -121,7 +120,6 @@ public void WorldSoccerWinners ()
121120
document.Rules.Add(new SrgsRule[] {winnerRule, ruleEurope, ruleSAmerica});
122121
document.Root = winnerRule;
123122
}
124-
125123
```
126124
127125
]]></format>
@@ -236,7 +234,7 @@ public void WorldSoccerWinners ()
236234
## Examples
237235
The following example creates a grammar that recognizes the phrase "A nation that has won the World Cup is" followed by the name of a country/region that has won the World Cup. The example uses the <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> element to build lists of acceptable country/region names from an array of <xref:System.String> objects. The example then adds one of the resulting <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> objects to their respective rules for European and South American countries/regions.
238236
239-
```
237+
```csharp
240238
public void WorldSoccerWinners ()
241239
{
242240
// Create a grammar from an SRGSDocument, create a new rule
@@ -305,10 +303,9 @@ public void WorldSoccerWinners ()
305303
## Examples
306304
The following example creates a grammar that recognizes the phrase "A nation that has won the World Cup is" followed by the name of a country/region that has won the World Cup. The example uses the <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> object to build lists of acceptable country/region names from an array of <xref:System.Speech.Recognition.SrgsGrammar.SrgsItem> objects. Using the <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf.Add%2A> method, the example appends an <xref:System.Speech.Recognition.SrgsGrammar.SrgsItem> that contains the string "Italy" to the <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> object `oneOfEurope`.
307305
308-
```
306+
```csharp
309307
public void WorldSoccerWinners ()
310308
{
311-
312309
// Create an SrgsDocument, create a new rule
313310
// and set its scope to public.
314311
SrgsDocument document = new SrgsDocument();

xml/System.Speech.Recognition.SrgsGrammar/SrgsRuleRef.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
## Examples
106106
The following example creates a grammar that recognizes the phrase "A nation that has won the World Cup is" followed by the name of a country that has won the World Cup. After creating the <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> object `winnerRule` and giving it the string identifier `WorldCupWinner`, the example appends the string "A nation that has won the World Cup is" to the rule. Using <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> objects, the example then builds a list of European countries/regions and a list of South American countries/regions, and adds each list to its respective rule, `ruleEurope` or `ruleSAmerica`. The example then creates rule references for `ruleEurope` and `ruleSAmerica` and adds them to the `WorldCupWinner` rule.
107107
108-
```
108+
```csharp
109109
public void WorldSoccerWinners ()
110110
{
111111
@@ -141,7 +141,7 @@ public void WorldSoccerWinners ()
141141
142142
The created grammar has the following form.
143143
144-
```
144+
```xml
145145
<grammar version="1.0" xml:lang="en-US" xmlns="http://www.w3.org/2001/06/grammar" root="WorldCupWinner">
146146
<rule id="WorldCupWinner" scope="public">
147147
<item> A nation that has won the world cup is </item>
@@ -218,7 +218,7 @@ public void WorldSoccerWinners ()
218218
219219
The second method, `CreateGrammarForRoute`, creates an <xref:System.Speech.Recognition.SrgsGrammar.SrgsDocument> element named `grammar` with a rule reference specified by the `Uri` passed to it by `GrammarUrlForRoute`. Note that the variable named _route is a member of an enclosing class.
220220
221-
```
221+
```csharp
222222
private Uri GrammarUrlForRoute(string route)
223223
{
224224
return new Uri("http://localhost/MyBus/MyBusLocations.grxml#LocationsForRoute" + route);
@@ -292,7 +292,7 @@ private SrgsDocument CreateGrammarForRoute()
292292
## Examples
293293
The following example creates a grammar for choosing the cities for a flight. The example constructs two <xref:System.Speech.Recognition.SrgsGrammar.SrgsRuleRef> instances, each of which specifies a semantic key. Both rule references target the same <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> object, named `cities`, but tag the recognition result from the rule reference with a different semantic key. The semantic key identifies a recognized city as the departure city or the arrival city for the flight. The handler for the <xref:System.Speech.Recognition.SpeechRecognitionEngine.SpeechRecognized> event uses the keys to retrieve the semantics values created using <xref:System.Speech.Recognition.SrgsGrammar.SrgsNameValueTag.%23ctor%2A> from the recognition result.
294294
295-
```
295+
```csharp
296296
using System;
297297
using System.Speech.Recognition;
298298
using System.Speech.Recognition.SrgsGrammar;

xml/System.Speech.Recognition.SrgsGrammar/SrgsSemanticInterpretationTag.xml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,20 @@
3838
## Remarks
3939
The default semantic format for System.Speech conforms to the W3C [Semantic Interpretation for Speech Recognition (SISR) Version 1.0](https://www.w3.org/TR/semantic-interpretation/), where the format for `tag` elements that contain script is `semantics/1.0`. You must specify the script for <xref:System.Speech.Recognition.SrgsGrammar.SrgsSemanticInterpretationTag> objects using this format. In the syntax of `semantics/1.0`:
4040
41-
- The Rule Variable of the containing rule element is identified by "out".
42-
43-
- The name of the object that has access to the Rule Variable of rule elements outside the containing rule element is identified by "rules".
44-
45-
- The result from the latest referenced rule that matches the utterance can be represented by "rules.latest()".
41+
- The Rule Variable of the containing rule element is identified by "out".
42+
- The name of the object that has access to the Rule Variable of rule elements outside the containing rule element is identified by "rules".
43+
- The result from the latest referenced rule that matches the utterance can be represented by "rules.latest()".
4644
4745
You can also associate a semantic value with a phrase in a grammar without using script, using the <xref:System.Speech.Recognition.SrgsGrammar.SrgsNameValueTag> object.
4846
49-
50-
5147
## Examples
5248
The following example creates a grammar for choosing the cities for a flight. The example uses <xref:System.Speech.Recognition.SrgsGrammar.SrgsSemanticInterpretationTag> to assign a semantic value to each city, which is the code for the city's airport. The example also uses <xref:System.Speech.Recognition.SrgsGrammar.SrgsSemanticInterpretationTag> to assign a separate semantic key for each of the two references made by the <xref:System.Speech.Recognition.SrgsGrammar.SrgsRuleRef> object named `cityRef` to the <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> object named `cities`. The semantic keys identify a recognized city as the departure city or the arrival city for the flight. The handler for the <xref:System.Speech.Recognition.SpeechRecognitionEngine.SpeechRecognized> event uses the keys to retrieve the semantics from the recognition result.
5349
5450
In the code example, "out" refers to the Rule Variable of the containing <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule>. The expression "out.LeavingFrom" refers to the property named `LeavingFrom` of the Rule Variable on the rule named `bookFlight`.
5551
5652
The expression "rules.flightCities" refers to the Rule Variable on the rule whose <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.Id%2A> is `flightCities`, and which is the target of a rule reference. In the example, the expression "out.LeavingFrom=rules.flightCities;" assigns the value from the rule whose <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.Id%2A> is `flightCities` to the property named `LeavingFrom` of the Rule Variable on the rule named `bookFlight`. See [Semantic Results Content](https://msdn.microsoft.com/library/622291af-615c-4a15-9014-2933aa3f89fe), [Grammar Rule Name Referencing](https://msdn.microsoft.com/library/0777e975-8665-4cc3-957b-752743cb1bb9), and [Grammar Rule Reference Referencing](https://msdn.microsoft.com/library/dec3a809-9aa2-4139-893f-3a549ca1e03e) for more information.
5753
58-
```
54+
```csharp
5955
using System;
6056
using System.Speech.Recognition;
6157
using System.Speech.Recognition.SrgsGrammar;
@@ -136,7 +132,6 @@ namespace SampleRecognition
136132
}
137133
}
138134
}
139-
140135
```
141136
142137
The following is the XML form of the grammar generated by the code in the example above.

xml/System.Speech.Recognition.SrgsGrammar/SrgsToken.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
## Examples
162162
The grammar in the following example contains slang words and also has an uncommon word: "whatchamacallit". Adding a custom, inline pronunciation using the <xref:System.Speech.Recognition.SrgsGrammar.SrgsToken.Pronunciation%2A> property of the <xref:System.Speech.Recognition.SrgsGrammar.SrgsToken> class can improve the accuracy of recognition for the word "whatchamacallit" as well as for the entire phrase that contains it. The example uses phones from the Microsoft Universal Phone Set (UPS) to define the custom pronunciations.
163163
164-
```
164+
```csharp
165165
using System;
166166
using System.Speech.Recognition;
167167
using System.Speech.Recognition.SrgsGrammar;
@@ -236,7 +236,6 @@ namespace SampleRecognition
236236
}
237237
}
238238
}
239-
240239
```
241240
242241
]]></format>

xml/System.Speech.Recognition/Choices.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ public Grammar CreatePhonePhrase()
551551
The following example creates a speech recognition grammar for changing the background color.
552552
553553
```csharp
554-
555554
private Grammar CreateColorChoice()
556555
{
557556
@@ -569,7 +568,6 @@ private Grammar CreateColorChoice()
569568
570569
return grammar;
571570
}
572-
573571
```
574572
575573
]]></format>

xml/System.Speech.Recognition/Grammar.xml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,9 @@ private static Grammar CreateGrammarFromFile()
6565
citiesGrammar.Name = "SRGS File Cities Grammar";
6666
return citiesGrammar;
6767
}
68-
6968
```
7069
7170
```xml
72-
7371
<?xml version="1.0" encoding="UTF-8" ?>
7472
<grammar version="1.0" xml:lang="en-US"
7573
xmlns="http://www.w3.org/2001/06/grammar"
@@ -203,7 +201,6 @@ private static Grammar CreateGrammarFromFile()
203201
The following example creates a speech recognition grammar from a local SRGS file (cities.xml) using a file stream. The content of the cities.xml file appears following C# example.
204202
205203
```csharp
206-
207204
// Load a cities grammar from an I/O stream and
208205
// return the new grammar.
209206
private static Grammar CreateGrammarFromStream()
@@ -217,7 +214,6 @@ private static Grammar CreateGrammarFromStream()
217214
```
218215
219216
```xml
220-
221217
<?xml version="1.0" encoding="UTF-8" ?>
222218
<grammar version="1.0" xml:lang="en-US"
223219
xmlns="http://www.w3.org/2001/06/grammar"
@@ -393,7 +389,6 @@ private static Grammar CreateSrgsDocumentGrammar()
393389
394390
return citiesGrammar;
395391
}
396-
397392
```
398393
399394
]]></format>
@@ -469,11 +464,9 @@ private static Grammar CreateGrammarFromFile()
469464
citiesGrammar.Name = "SRGS File Cities Grammar";
470465
return citiesGrammar;
471466
}
472-
473467
```
474468
475469
```xml
476-
477470
<?xml version="1.0" encoding="UTF-8" ?>
478471
<grammar version="1.0" xml:lang="en-US"
479472
xmlns="http://www.w3.org/2001/06/grammar"
@@ -564,7 +557,6 @@ private static Grammar CreateGrammarFromFile()
564557
The following example loads a local SRGS file (cities.xml) from a file stream and specifies a rule to use as the root of the grammar. The content of the cities.xml file appears in the XML example that follows the C# example.
565558
566559
```csharp
567-
568560
// Load a cities grammar from an I/O stream, use a specific
569561
// rule as the root of the grammar, and return the new grammar.
570562
private static Grammar CreateGrammarFromStream2()
@@ -577,7 +569,6 @@ private static Grammar CreateGrammarFromStream2()
577569
```
578570
579571
```xml
580-
581572
<?xml version="1.0" encoding="UTF-8" ?>
582573
<grammar version="1.0" xml:lang="en-US"
583574
xmlns="http://www.w3.org/2001/06/grammar"
@@ -733,7 +724,6 @@ namespace SampleRecognition
733724
}
734725
}
735726
}
736-
737727
```
738728
739729
]]></format>
@@ -801,7 +791,6 @@ namespace SampleRecognition
801791
The following example loads a local SRGS file (cities.xml) from a file and specifies a rule to use as the root of the grammar. The content of the cities.xml file appears in the XML example that follows the C# example.
802792
803793
```csharp
804-
805794
// Load a cities grammar from a local file, use a specific
806795
// rule as the root of the grammar, and return the new grammar.
807796
private static Grammar CreateGrammarFromFile2()
@@ -813,7 +802,6 @@ private static Grammar CreateGrammarFromFile2()
813802
```
814803
815804
```xml
816-
817805
<?xml version="1.0" encoding="UTF-8" ?>
818806
<grammar version="1.0" xml:lang="en-US"
819807
xmlns="http://www.w3.org/2001/06/grammar"
@@ -962,7 +950,6 @@ private static Grammar CreateGrammarFromFile2()
962950
The following example loads a local SRGS file (shuttle.xml) from a file stream. The file contains a relative rule reference to a rule in the cities.xml file, and specifies a base URI to use to resolve the rule reference. The content of the shuttle.xml and cities.xml files appears in the XML examples that follow the C# example.
963951
964952
```csharp
965-
966953
private static Grammar CreateGrammarFromStream3()
967954
{
968955
FileInfo file = new FileInfo(@".\shuttle.xml");
@@ -974,7 +961,6 @@ private static Grammar CreateGrammarFromStream3()
974961
```
975962
976963
```xml
977-
978964
<?xml version="1.0" encoding="UTF-8" ?>
979965
<grammar version="1.0" xml:lang="en-US"
980966
xmlns="http://www.w3.org/2001/06/grammar"
@@ -994,7 +980,6 @@ private static Grammar CreateGrammarFromStream3()
994980
```
995981
996982
```xml
997-
998983
<?xml version="1.0" encoding="UTF-8" ?>
999984
<grammar version="1.0" xml:lang="en-US"
1000985
xmlns="http://www.w3.org/2001/06/grammar"
@@ -1133,7 +1118,6 @@ private static Grammar CreateGrammarFromStream3()
11331118
The following example creates a speech recognition grammar in an <xref:System.Speech.Recognition.SrgsGrammar.SrgsDocument> that contains a relative rule reference to the cities.xml file, and specifies a URI to use to resolve the rule reference. The content of the cities.xml file appears in the XML example that follows the C# example.
11341119
11351120
```csharp
1136-
11371121
private static Grammar CreateSrgsDocumentGrammar3()
11381122
{
11391123
// Create the SrgsDocument.
@@ -1163,11 +1147,9 @@ private static Grammar CreateSrgsDocumentGrammar3()
11631147
11641148
return citiesGrammar;
11651149
}
1166-
11671150
```
11681151
11691152
```xml
1170-
11711153
<?xml version="1.0" encoding="UTF-8" ?>
11721154
<grammar version="1.0" xml:lang="en-US"
11731155
xmlns="http://www.w3.org/2001/06/grammar"
@@ -1396,7 +1378,6 @@ private static Grammar CreateSrgsDocumentGrammar3()
13961378
The following example writes information about a <xref:System.Speech.Recognition.Grammar> object to the [console](https://go.microsoft.com/fwlink/?LinkId=159613).
13971379
13981380
```csharp
1399-
14001381
private static void DumpGrammarStatus(Grammar item)
14011382
{
14021383
Console.WriteLine("Grammar name is {0}:", item.Name);
@@ -1498,7 +1479,6 @@ private static void DumpGrammarStatus(Grammar item)
14981479
The following example writes information about a <xref:System.Speech.Recognition.Grammar> object to the [console](https://go.microsoft.com/fwlink/?LinkId=159613).
14991480
15001481
```csharp
1501-
15021482
private static void DumpGrammarStatus(Grammar item)
15031483
{
15041484
Console.WriteLine("Grammar name is {0}:", item.Name);
@@ -1600,7 +1580,6 @@ private static void DumpGrammarStatus(Grammar item)
16001580
The following example creates two <xref:System.Speech.Recognition.Grammar> objects, one for digits and one for fractions. The Grammar objects are assigned names and relative weights and priorities, and loaded by an in-process speech recognizer. The `CreateDigitsGrammar`, `CreateFractionsGrammar`, and `recognizer_SpeechRecognized` methods are not shown here.
16011581
16021582
```csharp
1603-
16041583
// Create a Grammar for recognizing numeric digits.
16051584
Grammar digitsGrammar = CreateDigitsGrammar();
16061585
digitsGrammar.Name = "Digits Grammar";
@@ -1673,7 +1652,6 @@ recognizer.RecognizeAsync(RecognizeMode.Multiple);
16731652
The following example creates two <xref:System.Speech.Recognition.Grammar> objects, one for digits and one for fractions. The <xref:System.Speech.Recognition.Grammar> objects are assigned names and relative weights and priorities, and loaded by an in-process speech recognizer. The `CreateDigitsGrammar`, `CreateFractionsGrammar`, and `recognizer_SpeechRecognized` methods are not shown here.
16741653
16751654
```csharp
1676-
16771655
// Create a Grammar for recognizing numeric digits.
16781656
Grammar digitsGrammar = CreateDigitsGrammar();
16791657
digitsGrammar.Name = "Digits Grammar";
@@ -1782,7 +1760,6 @@ recognizer.RecognizeAsync(RecognizeMode.Multiple);
17821760
The following example writes information about a <xref:System.Speech.Recognition.Grammar> object to the [console](https://go.microsoft.com/fwlink/?LinkId=159613).
17831761
17841762
```csharp
1785-
17861763
private static void DumpGrammarStatus(Grammar item)
17871764
{
17881765
Console.WriteLine("Grammar name is {0}:", item.Name);
@@ -1963,7 +1940,6 @@ public partial class Form1 : Form
19631940
The following example creates two <xref:System.Speech.Recognition.Grammar> objects, one for digits and one for fractions. The <xref:System.Speech.Recognition.Grammar> objects are assigned names and relative weights and priorities, and loaded by an in-process speech recognizer. The `CreateDigitsGrammar`, `CreateFractionsGrammar`, and `recognizer_SpeechRecognized` methods are not shown here.
19641941
19651942
```csharp
1966-
19671943
// Create a Grammar for recognizing numeric digits.
19681944
Grammar digitsGrammar = CreateDigitsGrammar();
19691945
digitsGrammar.Name = "Digits Grammar";

0 commit comments

Comments
 (0)