You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by mb...@apache.org on 2007/12/05 16:58:43 UTC

svn commit: r601380 - in /incubator/uima/sandbox/trunk/RegularExpressionAnnotator: docbook/RegexAnnotatorUserGuide/ src/main/java/org/apache/uima/annotator/regex/ src/main/java/org/apache/uima/annotator/regex/extension/ src/main/java/org/apache/uima/an...

Author: mbaessler
Date: Wed Dec  5 07:58:43 2007
New Revision: 601380

URL: http://svn.apache.org/viewvc?rev=601380&view=rev
Log:
UIMA-666

update normalization interface with additional ruleID information

https://issues.apache.org/jira/browse/UIMA-666

Modified:
    incubator/uima/sandbox/trunk/RegularExpressionAnnotator/docbook/RegexAnnotatorUserGuide/regexAnnotatorUserGuide.xml
    incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/Feature.java
    incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/extension/Normalization.java
    incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/impl/Feature_impl.java
    incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/impl/RegExAnnotator.java
    incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/java/org/apache/uima/annotator/regex/CustomTestNormalizer.java

Modified: incubator/uima/sandbox/trunk/RegularExpressionAnnotator/docbook/RegexAnnotatorUserGuide/regexAnnotatorUserGuide.xml
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/RegularExpressionAnnotator/docbook/RegexAnnotatorUserGuide/regexAnnotatorUserGuide.xml?rev=601380&r1=601379&r2=601380&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/RegularExpressionAnnotator/docbook/RegexAnnotatorUserGuide/regexAnnotatorUserGuide.xml (original)
+++ incubator/uima/sandbox/trunk/RegularExpressionAnnotator/docbook/RegexAnnotatorUserGuide/regexAnnotatorUserGuide.xml Wed Dec  5 07:58:43 2007
@@ -1016,9 +1016,9 @@
 
    /* (non-Javadoc)
     * @see org.apache.uima.annotator.regex.extension.Normalization
-    *		#normalize(java.lang.String)
+    *		#normalize(java.lang.String, java.lang.String)
     */
-   public String normalize(String input) {
+   public String normalize(String input, String ruleId) {
       
       //implement your custom normalization
       String result = ...
@@ -1443,10 +1443,12 @@
  * perform a custom normalization on the given input string.
  * 
  * @param input input string which should be normalized
+ *
+ * @param ruleID rule ID of the matching rule
  * 
  * @return String - normalized input string 
  */
-public String normalize(String input) throws Exception;
+public String normalize(String input, String ruleID) throws Exception;
 }]]></programlisting>
 	</para>
 </appendix>

Modified: incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/Feature.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/Feature.java?rev=601380&r1=601379&r2=601380&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/Feature.java (original)
+++ incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/Feature.java Wed Dec  5 07:58:43 2007
@@ -69,6 +69,6 @@
    * 
    * @return returns the normalization type for this feature.
    */
-  public String normalize(String input) throws Exception;
+  public String normalize(String input, String ruleId) throws Exception;
 
 }

Modified: incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/extension/Normalization.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/extension/Normalization.java?rev=601380&r1=601379&r2=601380&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/extension/Normalization.java (original)
+++ incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/extension/Normalization.java Wed Dec  5 07:58:43 2007
@@ -31,7 +31,9 @@
  * 
  * @param input input string which should be normalized
  * 
+ * @param ruleID rule ID of the matching rule
+ * 
  * @return String - normalized input string 
  */
-public String normalize(String input) throws Exception;
+public String normalize(String input, String ruleID) throws Exception;
 }

Modified: incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/impl/Feature_impl.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/impl/Feature_impl.java?rev=601380&r1=601379&r2=601380&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/impl/Feature_impl.java (original)
+++ incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/impl/Feature_impl.java Wed Dec  5 07:58:43 2007
@@ -91,15 +91,13 @@
       return this.feature;
    }
 
-   /*
-    * (non-Javadoc)
-    * 
-    * @see org.apache.uima.annotator.regex.Feature#normalize(java.lang.String)
+   /* (non-Javadoc)
+    * @see org.apache.uima.annotator.regex.Feature#normalize(java.lang.String, java.lang.String)
     */
-   public String normalize(String input) throws Exception {
+   public String normalize(String input, String ruleId) throws Exception {
       // check normalizer type
       if (this.normalizationType == Feature.CUSTOM_NORMALIZATION) {
-         return this.normalizer.normalize(input);
+         return this.normalizer.normalize(input, ruleId);
       } else if (this.normalizationType == Feature.TO_LOWER_NORMALIZATION) {
          return input.toLowerCase();
       } else if (this.normalizationType == Feature.TO_UPPER_NORMALIZATION) {

Modified: incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/impl/RegExAnnotator.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/impl/RegExAnnotator.java?rev=601380&r1=601379&r2=601380&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/impl/RegExAnnotator.java (original)
+++ incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/main/java/org/apache/uima/annotator/regex/impl/RegExAnnotator.java Wed Dec  5 07:58:43 2007
@@ -679,7 +679,8 @@
                      // try to set the normalized feature value, if no
                      // normalization was specified for the feature, the
                      // original feature value is set
-                     featureValue = features[f].normalize(featureValue);
+                     featureValue = features[f].normalize(featureValue, concept
+                           .getRules()[ruleIndex].getId());
                   } catch (Exception ex) {
                      throw new RegexAnnotatorProcessException(
                            "regex_annotator_error_normalizing_feature_value",
@@ -779,6 +780,20 @@
             String featureValue = replaceMatchGroupValues(updateFeatures[f]
                   .getValue(), matcher);
 
+            // do featureValue normalization
+            try {
+               // try to set the normalized feature value, if no
+               // normalization was specified for the feature, the
+               // original feature value is set
+               featureValue = updateFeatures[f].normalize(featureValue, concept
+                     .getRules()[ruleIndex].getId());
+            } catch (Exception ex) {
+               throw new RegexAnnotatorProcessException(
+                     "regex_annotator_error_normalizing_feature_value",
+                     new Object[] { featureValue, updateFeatures[f].getName() },
+                     ex);
+            }
+
             // set feature value at the annotation in dependence of the feature
             // type
             if (type == Feature.FLOAT_FEATURE) {
@@ -788,18 +803,8 @@
                annot.setIntValue(updateFeatures[f].getFeature(), Integer
                      .parseInt(featureValue));
             } else if (type == Feature.STRING_FEATURE) {
-               try {
-                  // try to set the normalized feature value, if no
-                  // normalization was specified for the feature, the
-                  // original feature value is set
-                  annot.setStringValue(updateFeatures[f].getFeature(),
-                        updateFeatures[f].normalize(featureValue));
-               } catch (Exception ex) {
-                  throw new RegexAnnotatorProcessException(
-                        "regex_annotator_error_normalizing_feature_value",
-                        new Object[] { featureValue,
-                              updateFeatures[f].getName() }, ex);
-               }
+               annot.setStringValue(updateFeatures[f].getFeature(),
+                     featureValue);
             }
          } else if (type == Feature.REFERENCE_FEATURE) {
             // search for the referenced annotation ID

Modified: incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/java/org/apache/uima/annotator/regex/CustomTestNormalizer.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/java/org/apache/uima/annotator/regex/CustomTestNormalizer.java?rev=601380&r1=601379&r2=601380&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/java/org/apache/uima/annotator/regex/CustomTestNormalizer.java (original)
+++ incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/java/org/apache/uima/annotator/regex/CustomTestNormalizer.java Wed Dec  5 07:58:43 2007
@@ -29,7 +29,7 @@
    /* (non-Javadoc)
     * @see org.apache.uima.annotator.regex.Normalization#normalize(java.lang.String)
     */
-   public String normalize(String input) {
+   public String normalize(String input, String ruleId) {
       
       //replace input string with Test Output
       return "CustomTestNormalizerWorks";