Package ilog.rules.vocabulary.verbalization

Contains classes to associate terms and phrases to elements of the business object model.

See: Description

Package ilog.rules.vocabulary.verbalization Description

Contains classes to associate terms and phrases to elements of the business object model.

Overview

Verbalization is the process of associating terms and phrases to elements of the business object model. In terms of the API this means that a vocabulary element has a label and can be localized. The standard rule project verbalization is in English. In a rule project, each verbalization is stored as a series of key-value properties in a vocabulary (_<locale>.voc) file. There is one vocabulary file per locale, so a BOM entry can be associated with several vocabulary files.

The following is an extract from the vocabulary file for the loanvalidation-rules example project.

  # loan.Borrower
  loan.Borrower#concept.label = borrower

  # loan.Borrower.Bankruptcy
  loan.Borrower.Bankruptcy#concept.label = bankruptcy
  loan.Borrower.Bankruptcy.chapter#phrase.navigation = {chapter} of {this}
  loan.Borrower.Bankruptcy.date#phrase.navigation = {date} of {this}
  loan.Borrower.Bankruptcy.reason#phrase.navigation = {reason} of {this}
Using the API you can either extend an existing verbalization, based on the Business Action Language or create your own vocabulary. The most current scenario is to localize an existing verbalization. For example, if you wished to create a spanish verbalization, you will first make a copy of the existing vocabulary file and rename it _es.voc. After translating the vocabulary to spanish, you need to extend the verbalizer to handle syntactic rules in the spanish language.

Example

The following code example shows an example of how to to extend IlrDefaultVerbalizer:

public class IlrSpanishVerbalizer extends IlrDefaultVerbalizer
{
  public IlrSpanishVerbalizer() {
      setLabelBuilder(makeLabelBuilder());
  }
 
   public String verbalize(IlrVerbalizable verbalizable, IlrVerbalizationContext context)
      throws IlrVerbalizationException {

    StringBuffer buff = new StringBuffer();
    String label = context.isPlural() ? getLabelBuilder().getDisplayPluralLabel(
        verbalizable, this, context) : getLabelBuilder().getDisplayLabel(verbalizable,
        this, context);
    String articleStr = getArticleBuilder().getArticle(context, verbalizable);
    if (articleStr != null) {
      buff.append(articleStr);
      if (articleStr.length() != 0 && !articleStr.endsWith("'"))
        if (buff.length() > 0 && buff.charAt(buff.length() - 1) != ' ')
          buff.append(" ");
    }
    buff.append(label);
    return buff.toString();
  }

  protected IlrArticleBuilder makeArticleBuilder() {
    return new IlrSpanishArticleBuilder(this);
  }

  protected IlrPluralBuilder makePluralBuilder() {
    return new IlrSpanishPluralBuilder();
  }
 
  protected IlrLabelBuilder makeLabelBuilder() {
      return new IlrSpanishLabelBuilder();
  }
 
  protected IlrTermBuilder makeTermBuilder() {
    return new IlrSpanishTermBuilder();  
  }

  public IlrGender getDefaultGender() {
    return IlrGender.MALE_LITERAL;
  }
 
  public IlrGender[] getSupportedGenders() {
    return new IlrGender[] { IlrGender.MALE_LITERAL, IlrGender.FEMALE_LITERAL };
  }

  public String getGetterTemplate(IlrSentence sentence, List synRoles) {
     ...
  }
 
  public String getSetterTemplate(IlrSentence sentence, List synRoles) {
     ...
  }

  public String getPredicateGetterTemplate(IlrSentence sentence, List synRoles) {
     ...
  }

  public String getPredicateSetterTemplate(IlrSentence sentence, List synRoles)
  {
     ...
  }
 
  public String getCollectionAddTemplate(IlrSentence sentence, List synRoles) {
     ...
  }
 
  public  String getCollectionRemoveTemplate(IlrSentence sentence, List synRoles) {
     ...
  }
}
For more information on how to extend IlrDefaultVerbalizer, see the sample, Rule Studio Authoring Extensions in the ILOG JRules documentation.

Since:
JRules 6.0

Rule Designer API

© Copyright IBM Corp. 1987, 2017