Package org.apache.uima.annotator.regex

Examples of org.apache.uima.annotator.regex.Rule


            }

            // 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);
View Full Code Here


/* (non-Javadoc)
   * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
   */
  public int compare(Rule r1, Rule r2) {
   
    Rule rule1 = r1;
    Rule rule2 = r2;
   
    if(rule1.getConfidence() < rule2.getConfidence()) {
       return 1;
    }
    else if (rule1.getConfidence() > rule2.getConfidence()) {
       return -1;
    }
    else {
       return 0;
    }
View Full Code Here

TOP

Related Classes of org.apache.uima.annotator.regex.Rule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.