DataFlux Data Management Studio 2.6: User Guide

Grammar Editor

A Grammar is a set of rules that represent expected patterns of words in a given context. Once the parsing system identifies the basic categories for each word (through the Vocabulary), the patterns for that phrase are then compared against the Grammar. The ideal is for every possible pattern of categories to be found in the Grammar with no duplicates. However, this is not very realistic. What you should strive for is to fully identify all of the common and some of the less common patterns, and resolve any ambiguities through well-thought-out adjustments of the rule priorities.

Note Note: A Grammar file is stored in a proprietary format. To help ensure Grammar integrity, you should not attempt to create or edit a Grammar file directly, but always through the Grammar Editor.

Building Grammars

You can use the Customize Grammar Editor to build Grammars. We recommend you build one Grammar per parse definition, so repeat the following steps for each parse definition.

  1. Open the Grammar Editor Screen. On the Customize main screen, choose Tools > Grammar Editor. The Grammar Editor dialog appears.
  2. Set Your Locale. Select Options > Set Locale. The Select Locale dialog appears. Click on the appropriate locale, and then click OK. The locale setting is saved from session to session, so you do not need to specify it again unless you need to build a Grammar for a different locale.
  3. Create a New Grammar. On the Grammar Editor dialog, choose File > New. Two top-level containers appear on the Grammar dialog, one for basic categories and one for derived categories. Also, one basic category is always created by default for every Grammar: the NUM category that represents any numeric component in a pattern rule.
  4. Create Basic Categories in a Grammar. Select Edit > Add Category. The Add Category dialog appears. Enter an abbreviation and a descriptive name for your new category, select Basic, and then click OK. You have now created one new basic category, which appears in the Grammar Editor dialog. Repeat this as necessary to establish the basic category types you want to create. For a name parse definition, these might be things like a first name word category, a middle name word category and a last name word category, among others.
  5. Create Derived Categories in a Grammar. After creating several basic categories, you can create derived categories (which are essentially pattern variations) that are built upon those basic categories or on other derived categories. Select Edit > Add Category. The Add Category dialog appears. Enter an abbreviation and a descriptive name for your new category, select Derived, and then click OK. You have now created a new derived category, which appears on the Grammar Editor dialog. Repeat this step as necessary to create new derived categories.
  6. Populate Derived Categories with Rules Built on Other Categories. Select a newly created derived category, and then choose Edit > Add Rule. New fields appear on the right side of the Grammar Editor dialog, displaying the rules for the selected derived category. Click Add to build a new rule from the available categories. A rule must contain at least one category, but can contain many. After creating the new pattern rule from the given category list, assign a Priority. Medium is the default priority for newly created rules. A derived category must have at least one rule, but it can have many as well. Repeat this step as necessary to create new rules for the derived categories.
  7. Save the Grammar. Now that your Grammar is beginning to take shape, save it. Select File > Save. If this is a newly built Grammar, Customize will prompt you for a name.

Modifying Grammars

There are several ways you can modify Grammars.

Add a category to an existing Grammar

  1. On the Grammar Editor dialog, choose File > Open. The Open dialog opens.
  2. Select the Grammar to which you are adding a category, and then click Open. The Grammar's details appear on the Grammar Editor dialog.
  3. SelectEdit > Add Category. The Add Category dialog appears.
  4. Enter an abbreviation and a descriptive name for your new category, select Basic, and then click OK.

Add a rule to an existing Grammar derived category

  1. On the Grammar Editor dialog, choose File > Open. The Open dialog opens.
  2. Select the Grammar that contains the derived category to which you are adding a rule, and then click Open. The Grammar's details appear on the Grammar Editor dialog.
  3. In the tree view, select the derived category to which you want to add a rule.
  4. Select Edit > Add Rule. New fields appear on the right side of the Grammar Editor dialog, displaying the rules for the selected derived category. Click Add to build a new rule from the available categories, and then assign a Priority.

Modify a category's abbreviation

  1. On the Grammar Editor dialog, choose File > Open. The Open dialog opens.
  2. Select the Grammar that contains the category whose abbreviation you want to change, and then click Open. The Grammar's details appear on the Grammar Editor dialog.
  3. In the tree view, select the category whose abbreviation you want to change.
  4. SelectEdit > Change Category Abbreviation. The Change Category Abbreviation dialog appears.
  5. Edit the abbreviation, and then click OK.

Modify a category's name

  1. On the Grammar Editor dialog, choose File > Open. The Open dialog opens.
  2. Select the Grammar that contains the category whose name you want to change, and then click Open. The Grammar's details appear on the Grammar Editor dialog.
  3. In the tree view, select the category whose name you want to change.
  4. On the right of the screen, change the text in the Name field.

Modify the priority or category assigned to a rule

  1. On the Grammar Editor dialog, choose File > Open. The Open dialog opens.
  2. Select the Grammar that contains the rule whose priorities or categories you want to change, and then click Open. The Grammar's details appear on the Grammar Editor dialog.
  3. In the tree view, select the category that contains the rule you want to change.
  4. On the right of the screen, under Category, select the rule you want to change.
  5. To change the rule's priority, select a new priority from the Priority drop-down.
  6. To change the rule's category, click Edit, use the Edit Rule Category dialog to select a new category, and then click OK.

Delete a category

  1. On the Grammar Editor dialog, choose File > Open. The Open dialog opens.
  2. Select the Grammar that contains the category you want to delete, and then click Open. The Grammar's details appear on the Grammar Editor dialog.
  3. In the tree view, select the category you want to delete.
  4. SelectEdit > Delete Category. The category is deleted immediately and without confirmation.

Note Note: If the category you are attempting to delete is used in a rule for another category, you will not be able to delete the category. Instead, an error message will appear and the deletion will abort.

CautionCaution: When you attempt to delete categories that are used inside other categories, a warning message will tell you the category might become invalid if you delete it here. Avoid deleting categories that are used by other category rules. You may corrupt the entire Grammar. To ensure this is not a problem, if you want to delete a category from your Grammar, delete or modify all the rules that reference the category you want to delete.

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

Doc ID: dfU_Cstm_Gram_15000.html