Rss Categories

Grammar Editor Reference

Reference Number: AA-01117 Views: 7852 0 Rating/ Voters

The Grammar Editor screen is used to build new grammars and lexicons or troubleshoot existing ones.

The Grammar Editor tab is divided into 3 frames that will be referred to as :

Grammar Editor Frame

Main frame in the middle

Output Frame

Frame on bottom left

Grammar List Frame

Frame on bottom right

Grammar Editor Frame

This is the main frame in which grammars or custom lexicon files are built or edited. New files can be created from small built-in templates using :

File > New > New ABNF Grammar 

 - or -

File > New > New GrXML Grammar

 - or -

File > New > New Lexicon

An existing grammar or lexicon can be selected from the Grammar List Frame on the lower right corner by right clicking on the grammar and selecting Edit Grammar. Note that both GrXML and ABNF grammars as well as both sampa and lumenvox format lexicons can be edited using the editor.

Whenever editing GrXML grammar documents, or custom lexicons using this editor, context-aware auto-complete will assist you in providing hints as to options available to you, as well as showing common lists of available parameters and values where available. Auto-complete will automatically appear as you type, allowing you to select from a list of the displayed options.

See the SRGS Introduction and Lexicons articles for more detailed information on editing and syntax when working with grammars and lexicons.

There are 3 buttons below the Grammar Editor Frame that assist you while editing grammars: 

Once the grammar is completed, you can test the semantic interpretations returned by parsing some sample input text entered in the text box to the left of the Parse button. The interpretation result or any errors in grammar compilation will be displayed in the Output Frame. Note that the radio buttons in the Grammar List affect parsing.

This saves the grammar being edited in Speech Tuner. This does not save a copy to the original file location. It just saves a copy in memory so that changes are not lost while you edit a different grammar.

Reverts out all changes made to the grammar. If the grammar was originally loaded from file, this button returns the grammar to the original text loaded from the file. If the grammar was edited by creating a new grammar in Speech Tuner, using this button will revert it back to default grammar creation template i.e. reverts all your changes so care should be taken while reverting grammars.

While editing custom lexicons, the Apply and Revert buttons described above function the same, while the Parse button above is replaced with a Validate button:

When editing lexicons, you may want to validate the document to ensure the XML formatting is correct, the specified lexicon alphabet (sampa or lumenvox) is supported and also that the pronunciation references are valid. This can be done by clicking the Validate button. Any issues encountered will be displayed in the Output Frame 

Output Frame

When editing a grammar, this area displays the semantic interpretation of the input text entered to the text box to the left of the Parse button when the Parse button is clicked. It also shows grammar compilation errors if a parse could not be obtained.

For each selected grammar in the Grammar List (or the currently-active grammar if Parse with Grammar in Editor Only is selected), the output will contain:

  1. The number of parses through the grammar. This is the number of distinct paths the grammar allows for the given input.
  2. The number of interpretations for the input.
  3. parse tree for each parse, showing the exact path the input took through the grammar.
  4. The value of each interpretation.

When editing a lexicon, this area displays any syntax errors encountered when processing the lexicon. Syntax errors may be related to the general formatting of the XML in the document, or perhaps any incorrect or invalid phonemes being referenced that may not be appropriate for the language specified.

Grammar List Frame

This is the lower right frame. It displays the same information as shown in the summary view. This area displays a list of grammars and lexicons used in the currently loaded call data, filtered by menu or grammar set (if selected). For each grammar or lexicon, you can see its URL, the number of times it is referenced by interactions, the vocabulary size (the total number of unique words in the grammar), if appropriate, and any errors associated with it.

The radio buttons at the top control which grammar(s) is used for parsing. Selecting Parse with Grammar in Editor Only causes the parser to only parse against the grammar that is currently being edited. You can change this behavior by selecting Parse with All Selected Grammars instead, which causes the parser to parse against every checked grammar:

This is useful when you wish to understand how multiple active grammars may interact with each other. It's generally a good practice to avoid allowing the same input to match against more than one grammar that is active at any time, unless your application is prepared to handle some more advanced disambiguation options.

You may also right-click a grammar from the list to bring up a context menu.

The context menu contains the following options:

Edit Grammar
Opens the selected grammar or lexicon in the Grammar Editor Frame

Remove All Grammars
Removes all grammars from the Speech Tuner context.

Keep Selection
Filters out all interactions that do not use this grammar/lexicon.

Exclude Selection
Filters out all interactions that use this grammar/lexicon.

Save Data to File...
Allows you to save the list of grammars to a file (in .CSV format).

Pronunciation Checker
Opens the Pronunciation Checker tool for the selected grammar.

Random Sentence Generator
Opens the Random Sentence Generator for the selected grammar.

Displays advanced information about the grammar or lexicon, including error strings and any additional debugging information.

The available properties are:

  • The grammar's URI.
  • Base URI if specified over MRCP.
  • The Reference Count, indicating how many times the grammar is used by interactions currently loaded into the tuner.
  • Vocabulary Size indicating the number of unique words in the grammar.
  • A dropdown allowing you to View Encoding as: different encoding formats.
  • The grammar Complexity Score, a rough measurement of the size and complexity of the grammar.
  • An Error String, if present.

Precompiled Grammars

Precompiled grammars were introduced in LumenVox Version 11.0, and allow the creation and use of binary precompiled grammars. The speech tuner was modified to accommodate this new set of features.  Using the 11.0 and later Speech Tuner, you can load these binary precompiled grammars from the File->Open menu as you would open any regular SRGS grammar.

Parses and testing can be performed against these precompiled grammars in a similar way to regular SRGS grammars. In fact, the Speech Tuner goes out of its way to minimize the differences between which type of grammar is being used, since internally, the ASR uses them in very similar ways.

Also starting with version 11.0, you may now specify a URI from where to load grammar files (SRGS or precompiled), which makes accessing remote files much easier, such as those hosted on HTTP servers.

The Speech Tuner can also be used to generate precompiled grammars. To do this, simply load or create an SRGS grammar, then right-click on that grammar's name tab at the top of the Grammar Editor Frame to display the Context-Menu, and select the "Save as precompiled grammar" option.

Because precompiled grammars cannot be edited, and their contents cannot be seen, whenever viewing or testing a precompiled grammar in the Grammar Editor, a message will be shown that indicates the original source of the grammar, so that it can be referred to if changes are needed.

See the Using Precompiled Grammars article for more details on using precompiled grammars.

Note that lexicon files cannot directly be saved in precompiled format, however any grammar that references a custom lexicon may be saved in precompiled format, which will include any referenced custom pronunciations from such as referenced lexicon.

Please Note: Whenever creating precompiled grammars, the SRGS contents of the grammars will be obfuscated, however the URL from where the grammar was created is added to the precompiled grammar and can be viewed within the Speech Tuner later (to help identify the source of the grammar), however this means that if your implementation specifies optional URI parameters when requesting the grammar, those parameters will also be visible, which may be a security concern, so care should be used in these cases.