Feedback

  • Contents
 

Use Grammar Weights and Probabilities

SRGS grammars support the usage of weights to specify the preference of matching a recognition of one response over another. For example, if your grammar prompted callers to speak the city from which they are calling, those city names may exist in multiple states, regions, or countries. By assigning weights to multiple instances of a word or phrase (token), you are specifying that one of them is more likely to be spoken over another. If you do not assign weight values to multiple instances of a word or phrase within a rule, all definitions of that word or phrase share the same likelihood of occurrence.

Note:

Only add weights in your grammars when tuning efforts provided evidence that they are necessary. Entering estimations of weights can result in decreased recognition confidence levels of accurate responses.

The following examples provide recognitions for the city of Springfield. In these examples, Springfield could indicate more than one state. Using weights in your grammar enables you to prefer Springfield, Missouri over Springfield, Illinois as a match to Springfield.

ABNF example of weight

#ABNF 1.0;
language en-us;
mode voice;
tag-format <semantics/1.0>;
root $Cities;
$Cities =
(/2.0/ springfield [missouri] 
 
{out.city="Springfield"; out.state="Missouri"}) 
 
 
|
(/1.2/ springfield [illinois] 
 
{out.city="Springfield"; out.state="Illinois"}) 
 
 
|
dallas [texas] {out.city="Dallas"; 
 
out.state="Texas"};

GrXML example of weight

<?xml version="1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar"
xml:lang="en-US"
root="cities"
mode="voice">
<rule id="cities">
<one-of>
<item 
 
weight="2.0">
Springfield
<item 
 
repeat="0-1">Missouri</item>
<tag>out.city="Springfield";out.state="Missouri";</tag>
</item>
<item 
 
weight="1.2">
Springfield
<item 
 
repeat="0-1">Illinois</item>
<tag>out.city="Springfield";out.state="Illinois";</tag>
</item>
<item>
Dallas
<tag>out.city="Dallas";out.state="Texas";</tag>
</item>
</one-of>
</rule>
</grammar>

For more information about SRGS weights, see http://www.w3.org/TR/grammar-spec/#S2.4.1.