DataFlux Data Management Studio 2.7: User Guide

Adding and Editing Grammars

Overview

Add a new grammar or update an existing grammar when the categories and rules in existing grammars do not meet your needs. To understand grammars, see the help for the Grammar Editor. See also the existing grammars on the Grammars tab. Use these sources to plan the basic categories, derived categories, and rules that you need.

NoteNote: The implementation of a grammar can be a complex task. If you are unfamiliar with grammars, you might want to attend a SAS QKB Customization training course. For information about training courses available from SAS, contact SAS Technical Support.

Add a Grammar and Some Basic Categories

This topic describes how to add a new grammar file to a locale in a QKB and add some basic categories. One reason to do this would be that you are adding a new vocabulary, and you need a new grammar and some basic categories to match the semantic types of the words in the new vocabulary.

The next display shows some of the basic categories listed in the EN Business Title grammar in the English locale in the SAS Quality Knowledge Base for Contact Information 24.


EN Business Title Grammar and Its Basic Categories

Two of the semantic types represented in the previous display are DEPT_W (Department Word) and GRADE_W (Grade Word).

Perform the following steps to add a new grammar file to a locale in a QKB and add some basic categories. It is assumed that you have opened the QKB from the Administration Riser, and the Grammars tab is displayed.

  1. Click the New Grammar button on the lower toolbar, or select New Grammar from the action menu on the lower toolbar. The New Grammar wizard opens.
  2. Enter a name and description for the new grammar and click Next.
  3. Select a locale for the grammar and click Finish. The new grammar appears in the grammar list, and the Grammar Editor opens.
  4. To add a new basic category, select the Basic Categories folder. Then select Edit > Add Category from the menu.
  5. In the Add Categories dialog, specify an abbreviation and a name for the category.

    The abbreviation is a shorthand name for the category. It is used to optimize readability when the category is displayed in an area with limited space, such as in a tree view. The name of the category is a full descriptive name. Both the abbreviation and the name of a basic category should be appropriate for a semantic type of a word in a vocabulary.
  6. Click OK to save the new category.
  7. Repeat the previous steps to add more basic categories, if desired.
  8. If desired, add derived categories and rules as described in the next topic.
  9. Select FileSave to save the new grammar. If SAS Data Management Studio is open, you will be prompted to reload the QKB.
  10. Click Yes to reload the QKB.

Add a Derived Category and Some Rules

This topic describes how to add derived category to an existing grammar file. One reason to do this would be that you want to create a rule for a new string pattern such as [Name] > [Given Name] [Family Name].

Derived categories represent sets of one or more rules that specify patterns that define a semantic concept. A pattern in a rule consists of one or more basic categories and/or other derived categories. For example, the next display shows the Occupation derived category.


Occupation Derived Category and Its Rules

The Occupation derived category can be derived by any of a number of rules, such as POSITION SEP_W DEPARTMENT. Each rule specifies a pattern containing one or more basic or derived categories, plus a Priority value.

Perform the following steps to add a derived category and some rules to an existing grammar file. It is assumed that you have opened the QKB from the Administration Riser, and the Grammars tab is displayed. It is assumed that you have a general idea what new rules you want to create, such as a rule for a string pattern such as [Name] > [Given Name] [Family Name].

  1. Double-click the grammar that you want to update. Alternatively, you could right-click a grammar and select Open, or select a grammar and then click the Open icon in the toolbar. The Grammar Editor displays the selected grammar.
  2. Click the plus sign beside the main Derived Category folder to expand it. Note the main derived categories, such as LEVEL, LOCATION, and OCCUPATION in the previous display.
  3. Click the plus sign beside a derived category to expand it, such as the OCCUPATION category. Note the rules within that category, such as POSITION SEP_W DEPARTMENT in the previous display.
  4. To add a new derived category, right-click the main Derived Categories folder or a derived category. Then select Add Category from the context menu.
  5. In the Add Categories dialog, specify an abbreviation and a name for the category.

    The abbreviation is a shorthand name for the category. It is used to optimize readability when the category is displayed in an area with limited space, such as in a tree view. The name of the category is a full descriptive name. Both the abbreviation and the name of a basic category should be appropriate for a semantic type of a word in a vocabulary.
  6. Click OK to save the new derived category.
  7. To add a rule within a derived category, right-click the derived category. Then select Add Rule from the context menu. The Rule properties panel for the current category displays on the right.
  8. Note the value in the Priority field of the panel. This value sets the priority for the rule that you are editing. At run time, if the software finds that an input string can be parsed in more than one way according to your grammar, it will choose the solution that uses the rules with the highest priorities. Use the selection arrow to change the Priority value as needed.
  9. Click Add in the right panel. The Add Rule Category dialog displays.
  10. Use this dialog to select a rule category. Click OK to save this category as a rule.
  11. Repeat steps 9 and 10 until you have added all of the desired categories in your rule.
  12. Select FileSave to save the grammar. If SAS Data Management Studio is open, you will be prompted to reload the QKB.
  13. Click Yes to reload the QKB.

Update Categories or Rules

You can update categories and rules from the context menu or from the Edit menu in the Edit Grammar dialog. For example, to add a category to a grammar, right-click a parent folder and select Add Category. Alternatively, select a parent folder, then select Edit > Add Category from the menu.

To change the abbreviation for a category, right-click a category and select Change Category Abbreviation.

To duplicate a category, right-click a category and select Duplicate Category. If the category is a derived category, all of the category's rules are also duplicated.

To add a rule, right-click a derived category and select Add Rule.

To copy and paste a rule, right-click a rule and select Copy Rule. Then select another derived category and select Paste Rule.

Related Topics

Documentation Feedback: yourturn@sas.com
Note: Always include the Doc ID when providing documentation feedback.

Doc ID: dfU_Cstm_Gram_15001.html