Advanced Semantic Interpretation

Advanced Semantic Interpretation

(MAY 2007) — In January, we talked about getting the most out of your applications by adding in semantic interpretation for speech recognition (SISR) tags.

This month, we're going to focus on some more advanced uses for SISR, with examples illustrated using the latest syntax per the April 2007 W3C SISR specification.

Formatting Results

For instance, results can be objects with multiple properties. The following call router example returns a person or department's name as a string and an extension as an integer:

root $name;

$name = ($alice| $bob | $support) {out = rules.latest()};

$alice = alice [jones] { = "Alice Jones"; out.extension = 101};

$bob = (robert | bob) [smith] { = "Bob Smith"; out.extension = 100};

$support = [technical] (support | service) { = "Support"; out.extension = 500;

Accessing Other Rules

Often it is useful to combine or evaluate the results of multiple matched rules. This is done through the use of an object called rules that contains as properties the rule variables for all currently visible rules (a rule is visible if and only if it is a child of the current rule in the parse tree).

The $name rule in the example above used a shortcut called rules. latest() (under older versions of SISR this was the $$ object) to get the SI information for the last matched rule.

You may also access rule variables by using rules.rulename where rulename is the name of the rule to access. So if we wanted to access the $bob rule's variable from the $name rule above, we would look at rules.bob and evaluate the results.

Getting Information from the Engine

SI script also gives you access to some information from the Speech Engine via special objects called meta variables.

To access the confidence score for a matched rule, look at meta.rulename.score. Using meta.latest().score works as well, and use meta.current() .score for the score for the rule you're currently in.

You can also obtain the raw text for a matched rule by using meta.rulename.text, and of course the latest() and current() properties work as well.

Learn More About SISR

If you would like to learn more about the latest version of SISR, you will want to watch our ongoing series of instructional videos about working with SISR. These videos cover the basics of semantic interpretation and go into more detail about the advanced features of SI script. More

You might also be well served by one of our training classes. We offer an entire training class devoted to SRGS grammars and SISR. More

How to Download the Latest Release

The most recent releases of the LumenVox Speech Engine support the very latest W3C recommendation for Semantic Interpretation for Speech Recognition. You'll need to be using version 7.5.300 or later in order to take advantage of all the examples in this bulletin.

If you would like information on downloading the latest release of the LumenVox Speech Engine, please contact us. It is a free download for users with current software maintenance packages.

SI Script vs. String Literals

The SISR specification allows for SISR tags to take one of two tag formats. The first, called string literals, causes the Engine to treat the contents of a tag as a simple string that is placed in the rule variable for that rule.

So the following grammar rule would return "bob" as a string were it matched:

$name = (bob | robert) {bob};

String literals are handy for simple lists where the speaker can only pick one option at a time, as the syntax is quick and easy to implement. The real drawback of relying too heavily on string literals is that there is no way to combine semantic interpretation from multiple rules.

To do that, one must switch to the SI script format. This tag format treats everything within a tag as ECMA Script. In order to address the current rule variable, SI script uses a variable called out (this variable was called $ in older versions of SISR).

The following rule using SI script is equivalent to the string literal example from above:

$name = (bob | robert) {out = "bob"};

SI script is much more powerful, but also more complex. The examples throughout this document use the SI script format.

To declare which format a grammar is using, a tag–format declaration is made in the header. For SI script, use the format semantics/1.0.2006 and use semantics /1.0.2006–literals for string literals.

Please note that these identifiers are slightly different than the W3C specification calls for; this difference is to ensure that LumenVox has backwards compatibility for grammars using older drafts of the SISR specification.

© 2016 LumenVox, LLC. All rights reserved.