}
// create new rule and add all rule settings
// additionally add a reference to the regex variables object
// to resolve regex variables
Rule rule = new Rule_impl(regex, matchStrategy, matchType, id,
confidence, featurePath, variables);
// ********************************
// get match type filter features
// ********************************
if (ruleList[r].getMatchTypeFilter() != null) {
// iterate over all filter features and add them to the rule
FeatureDocument.Feature[] filterFeatures = ruleList[r]
.getMatchTypeFilter().getFeatureArray();
for (int x = 0; x < filterFeatures.length; x++) {
String featureName = filterFeatures[x].getFeaturePath();
String featureValue = filterFeatures[x].getStringValue();
// create new filter feature and add them to the rule
FilterFeature filterFeature = new FilterFeature_impl(
featureName, featureValue);
rule.addFilterFeature(filterFeature);
}
}
// ***********************************************
// get all update match type annotation features
// ***********************************************
if (ruleList[r].getUpdateMatchTypeAnnotation() != null) {
// iterate over all match type annotation update features and add
// them to the rule
SetFeatureDocument.SetFeature[] updateFeatures = ruleList[r]
.getUpdateMatchTypeAnnotation().getSetFeatureArray();
for (int x = 0; x < updateFeatures.length; x++) {
String featureName = updateFeatures[x].getName();
String featureValue = updateFeatures[x].getStringValue();
int featureType = updateFeatures[x].getType().intValue();
int normalization = 0;
if (updateFeatures[x].getNormalization() != null) {
normalization = updateFeatures[x].getNormalization()
.intValue();
}
String implClass = updateFeatures[x].getClass1();
// create new feature and add them to the rule
Feature updateFeature = new Feature_impl(featureType,
featureName, featureValue, normalization, implClass);
rule.addUpdateFeature(updateFeature);
}
}
// **********************************
// get all exceptions for this rule
// **********************************
if (ruleList[r].getRuleExceptions() != null) {
// iterate over all match type annotation update features and add
// them to the rule
ExceptionDocument.Exception[] exceptions = ruleList[r]
.getRuleExceptions().getExceptionArray();
for (int x = 0; x < exceptions.length; x++) {
String exceptionMatchType = exceptions[x].getMatchType();
String regexPattern = exceptions[x].getStringValue();
// create new Exception object and add them to the rule
org.apache.uima.annotator.regex.RuleException exception = new RuleException_impl(
exceptionMatchType, regexPattern);
rule.addException(exception);
}
}
// add rule to the concept
concept.addRule(rule);