You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2015/01/16 14:11:00 UTC

svn commit: r1652399 - in /uima/ruta/trunk/ruta-core/src: main/java/org/apache/uima/ruta/engine/RutaModifier.java main/java/org/apache/uima/ruta/engine/StyleMapCreator.java test/java/org/apache/uima/ruta/engine/RutaModifierTest.java

Author: pkluegl
Date: Fri Jan 16 13:10:59 2015
New Revision: 1652399

URL: http://svn.apache.org/r1652399
Log:
UIMA-3866
- converted next two analysis engines

Modified:
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaModifier.java
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/StyleMapCreator.java
    uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/engine/RutaModifierTest.java

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaModifier.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaModifier.java?rev=1652399&r1=1652398&r2=1652399&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaModifier.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaModifier.java Fri Jan 16 13:10:59 2015
@@ -30,7 +30,6 @@ import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.uima.UimaContext;
-import org.apache.uima.analysis_component.JCasAnnotator_ImplBase;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.CASException;
@@ -38,39 +37,83 @@ import org.apache.uima.cas.FSIterator;
 import org.apache.uima.cas.Feature;
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
+import org.apache.uima.fit.descriptor.ConfigurationParameter;
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.apache.uima.ruta.type.RutaBasic;
 import org.apache.uima.tools.stylemap.StyleMapEntry;
 import org.apache.uima.util.FileUtils;
 
+/**
+ * The Modifier Analysis Engine can be used to create an additional view, which contains all textual
+ * modifications and HTML highlightings that were specified by the executed rules. This Analysis
+ * Engine can be applied, e.g., for anonymization where all annotations of persons are replaced by
+ * the string <code>Person</code>. Furthermore, the content of the new view can optionally be stored
+ * in a new HTML file. A descriptor file for this Analysis Engine is located in the folder
+ * <code>descriptor/utils</code> of a UIMA Ruta project.
+ * 
+ */
 public class RutaModifier extends JCasAnnotator_ImplBase {
+
   public static final String DEFAULT_MODIFIED_VIEW = "modified";
 
-  public static final String OUTPUT_LOCATION = "outputLocation";
+  /**
+   * This optional string parameter specifies the absolute path of the resulting file named
+   * <code>output.modified.html</code>. However, if an annotation of the type
+   * <code>org.apache.uima.examples.SourceDocumentInformation</code> is given, then the value of
+   * this parameter is interpreted to be relative to the URI stored in the annotation and the name
+   * of the file will be adapted to the name of the source file. If this functionality is activated
+   * in the preferences, then the UIMA Ruta Workbench adds the SourceDocumentInformation annotation
+   * when the user launches a script file. The default value of this parameter is empty. In this
+   * case no additional html file will be created.
+   */
+  public static final String PARAM_OUTPUT_LOCATION = "outputLocation";
 
-  public static final String OUTPUT_VIEW = "outputView";
+  @ConfigurationParameter(name = PARAM_OUTPUT_LOCATION, mandatory = false)
+  private String outputLocation;
 
-  private StyleMapFactory styleMapFactory;
+  /**
+   * This string parameter specifies the name of the style map file created by the Style Map Creator
+   * Analysis Engine, which stores the colors for additional highlightings in the modified view.
+   */
+  public static final String PARAM_STYLE_MAP = StyleMapCreator.PARAM_STYLE_MAP;
 
+  @ConfigurationParameter(name = PARAM_STYLE_MAP, mandatory = false)
   private String styleMapLocation;
 
-  private String[] descriptorPaths;
-
-  private String outputLocation;
+  /**
+   * This string parameter specifies the name of the view, which will contain the modified document.
+   * A view of this name must not yet exist. The default value of this parameter is
+   * <code>modified</code>.
+   */
+  public static final String PARAM_OUTPUT_VIEW = "outputView";
 
+  @ConfigurationParameter(name = PARAM_OUTPUT_VIEW, mandatory = false, defaultValue = DEFAULT_MODIFIED_VIEW)
   private String modifiedViewName;
 
+  /**
+   * This parameter can contain multiple string values and specifies the absolute paths where the
+   * style map file can be found.
+   */
+  public static final String PARAM_DESCRIPTOR_PATHS = RutaEngine.PARAM_DESCRIPTOR_PATHS;
+
+  @ConfigurationParameter(name = PARAM_DESCRIPTOR_PATHS, mandatory = false)
+  private String[] descriptorPaths;
+
+  private StyleMapFactory styleMapFactory;
+
   @Override
   public void initialize(UimaContext aContext) throws ResourceInitializationException {
     super.initialize(aContext);
-    styleMapLocation = (String) aContext.getConfigParameterValue(StyleMapCreator.STYLE_MAP);
-    descriptorPaths = (String[]) aContext.getConfigParameterValue(RutaEngine.PARAM_DESCRIPTOR_PATHS);
-    outputLocation = (String) aContext.getConfigParameterValue(RutaModifier.OUTPUT_LOCATION);
-    styleMapFactory = new StyleMapFactory();
-    modifiedViewName = (String) aContext.getConfigParameterValue(RutaModifier.OUTPUT_VIEW);
+    styleMapLocation = (String) aContext.getConfigParameterValue(PARAM_STYLE_MAP);
+    descriptorPaths = (String[]) aContext
+            .getConfigParameterValue(RutaEngine.PARAM_DESCRIPTOR_PATHS);
+    outputLocation = (String) aContext.getConfigParameterValue(RutaModifier.PARAM_OUTPUT_LOCATION);
+    modifiedViewName = (String) aContext.getConfigParameterValue(RutaModifier.PARAM_OUTPUT_VIEW);
     modifiedViewName = StringUtils.isBlank(modifiedViewName) ? DEFAULT_MODIFIED_VIEW
             : modifiedViewName;
+    styleMapFactory = new StyleMapFactory();
   }
 
   @Override

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/StyleMapCreator.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/StyleMapCreator.java?rev=1652399&r1=1652398&r2=1652399&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/StyleMapCreator.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/StyleMapCreator.java Fri Jan 16 13:10:59 2015
@@ -22,22 +22,42 @@ package org.apache.uima.ruta.engine;
 import java.io.IOException;
 
 import org.apache.uima.UimaContext;
-import org.apache.uima.analysis_component.JCasAnnotator_ImplBase;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
+import org.apache.uima.fit.descriptor.ConfigurationParameter;
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 
+/**
+ * This Analysis Engine can be utilized to create style map information, which is needed by the
+ * Modifier Analysis Engine in order to create highlightings for some annotations. Style map
+ * information can be created using the COLOR action. A descriptor file for this Analysis Engine is
+ * located in the folder <code>descriptor/utils</code> of a UIMA Ruta project.
+ * 
+ */
 public class StyleMapCreator extends JCasAnnotator_ImplBase {
 
-  private UimaContext context;
+  /**
+   * This parameter can contain multiple string values and specifies the absolute paths where the
+   * style map file can be found.
+   */
+  public static final String PARAM_DESCRIPTOR_PATHS = RutaEngine.PARAM_DESCRIPTOR_PATHS;
 
-  private StyleMapFactory styleMapFactory;
+  @ConfigurationParameter(name = PARAM_DESCRIPTOR_PATHS, mandatory = false)
+  private String[] descriptorPaths;
 
-  public static final String STYLE_MAP = "styleMap";
+  /**
+   * This string parameter specifies the name of the style map file created by the Style Map Creator
+   * Analysis Engine, which stores the colors for additional highlightings in the modified view.
+   */
+  public static final String PARAM_STYLE_MAP = "styleMap";
 
+  @ConfigurationParameter(name = PARAM_STYLE_MAP, mandatory = false)
   private String styleMapLocation;
 
-  private String[] descriptorPaths;
+  private UimaContext context;
+
+  private StyleMapFactory styleMapFactory;
 
   @Override
   public void initialize(UimaContext aContext) throws ResourceInitializationException {
@@ -46,7 +66,7 @@ public class StyleMapCreator extends JCa
       aContext = context;
     }
     if (aContext != null) {
-      styleMapLocation = (String) aContext.getConfigParameterValue(STYLE_MAP);
+      styleMapLocation = (String) aContext.getConfigParameterValue(PARAM_STYLE_MAP);
       descriptorPaths = (String[]) aContext
               .getConfigParameterValue(RutaEngine.PARAM_DESCRIPTOR_PATHS);
       styleMapFactory = new StyleMapFactory();

Modified: uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/engine/RutaModifierTest.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/engine/RutaModifierTest.java?rev=1652399&r1=1652398&r2=1652399&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/engine/RutaModifierTest.java (original)
+++ uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/engine/RutaModifierTest.java Fri Jan 16 13:10:59 2015
@@ -58,9 +58,9 @@ public class RutaModifierTest {
     TypeSystemDescription mergeTypeSystems = CasCreationUtils.mergeTypeSystems(tsds);
     aed.getAnalysisEngineMetaData().setTypeSystem(mergeTypeSystems);
     AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aed);
-    ae.setConfigParameterValue(RutaModifier.OUTPUT_LOCATION, "");
+    ae.setConfigParameterValue(RutaModifier.PARAM_OUTPUT_LOCATION, "");
     String viewName = "modified_for_testing";
-    ae.setConfigParameterValue(RutaModifier.OUTPUT_VIEW, viewName);
+    ae.setConfigParameterValue(RutaModifier.PARAM_OUTPUT_VIEW, viewName);
     ae.reconfigure();
     
     String scriptName = this.getClass().getSimpleName();