Added: 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/CreatedByVisitor.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/CreatedByVisitor.java?rev=1360586&view=auto
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/CreatedByVisitor.java
 (added)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/CreatedByVisitor.java
 Thu Jul 12 08:58:05 2012
@@ -0,0 +1,74 @@
+package org.apache.uima.textmarker.visitor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.textmarker.ScriptApply;
+import org.apache.uima.textmarker.TextMarkerElement;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.rule.RuleMatch;
+import org.apache.uima.textmarker.verbalize.TextMarkerVerbalizer;
+
+public class CreatedByVisitor implements TextMarkerInferenceVisitor {
+
+  public static final String TYPE = 
"org.apache.uima.textmarker.type.DebugCreatedBy";
+
+  public static final String FEATURE_RULE = "rule";
+
+  public static final String FEATURE_ANNOTATION = "annotation";
+
+  public static final String FEATURE_SCRIPT = "script";
+
+  public static final String FEATURE_ID = "id";
+
+  private List<FeatureStructure> fsList = new ArrayList<FeatureStructure>();
+
+  private TextMarkerVerbalizer verbalizer;
+
+  public CreatedByVisitor(TextMarkerVerbalizer verbalizer) {
+    super();
+    this.verbalizer = verbalizer;
+  }
+
+  public void beginVisit(TextMarkerElement element, ScriptApply result) {
+  }
+
+  public void endVisit(TextMarkerElement element, ScriptApply result) {
+  }
+
+  public void finished(TextMarkerStream stream, 
List<TextMarkerInferenceVisitor> visitors) {
+    for (FeatureStructure each : fsList) {
+      each.getCAS().addFsToIndexes(each);
+    }
+  }
+
+  public void annotationAdded(AnnotationFS annotation, RuleMatch creator) {
+    CAS cas = annotation.getCAS();
+    Type t = cas.getTypeSystem().getType(TYPE);
+    Feature featureRule = t.getFeatureByBaseName(FEATURE_RULE);
+    Feature featureAnnotation = t.getFeatureByBaseName(FEATURE_ANNOTATION);
+    Feature featureScript = t.getFeatureByBaseName(FEATURE_SCRIPT);
+    Feature featureId = t.getFeatureByBaseName(FEATURE_ID);
+
+    String ruleString = "provided";
+    String ruleScript = "";
+    int ruleId = -1;
+    if (creator != null) {
+      ruleString = verbalizer.verbalize(creator.getRule());
+      ruleId = creator.getRule().getId();
+      ruleScript = 
creator.getRule().getParent().getScript().getRootBlock().getNamespace();
+    }
+    FeatureStructure fs = cas.createFS(t);
+    fs.setStringValue(featureRule, ruleString);
+    fs.setFeatureValue(featureAnnotation, annotation);
+    fs.setIntValue(featureId, ruleId);
+    fs.setStringValue(featureScript, ruleScript);
+    fsList.add(fs);
+  }
+
+}

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/DebugInfoCollectorVisitor.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/DebugInfoCollectorVisitor.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/DebugInfoCollectorVisitor.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/DebugInfoCollectorVisitor.java
 Thu Jul 12 08:58:05 2012
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Stack;
 
+import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.textmarker.BlockApply;
 import org.apache.uima.textmarker.ScriptApply;
 import org.apache.uima.textmarker.TextMarkerBlock;
@@ -33,6 +34,7 @@ import org.apache.uima.textmarker.TextMa
 import org.apache.uima.textmarker.TextMarkerStatement;
 import org.apache.uima.textmarker.TextMarkerStream;
 import org.apache.uima.textmarker.rule.RuleApply;
+import org.apache.uima.textmarker.rule.RuleMatch;
 import org.apache.uima.textmarker.rule.TextMarkerRule;
 import org.apache.uima.textmarker.type.DebugScriptApply;
 import org.apache.uima.textmarker.verbalize.TextMarkerVerbalizer;
@@ -184,4 +186,8 @@ public class DebugInfoCollectorVisitor i
     return null;
   }
 
+  public void annotationAdded(AnnotationFS annotation, RuleMatch creator) {
+    
+  }
+
 }

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/DebugInfoFactory.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/DebugInfoFactory.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/DebugInfoFactory.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/DebugInfoFactory.java
 Thu Jul 12 08:58:05 2012
@@ -40,6 +40,7 @@ import org.apache.uima.textmarker.rule.R
 import org.apache.uima.textmarker.rule.RuleElement;
 import org.apache.uima.textmarker.rule.RuleElementMatch;
 import org.apache.uima.textmarker.rule.RuleMatch;
+import org.apache.uima.textmarker.rule.TextMarkerRule;
 import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
 import org.apache.uima.textmarker.type.DebugBlockApply;
 import org.apache.uima.textmarker.type.DebugEvaluatedCondition;
@@ -179,6 +180,8 @@ public class DebugInfoFactory {
     dra.setElement(verbalizer.verbalize(ruleApply.getElement()));
     dra.setApplied(ruleApply.getApplied());
     dra.setTried(ruleApply.getTried());
+    dra.setId(((TextMarkerRule)ruleApply.getElement()).getId());
+    
dra.setScript(ruleApply.getElement().getParent().getScript().getRootBlock().getNamespace());
     dra.setBegin(begin);
     dra.setEnd(end);
     if (timeInfo != null) {

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/InferenceCrowd.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/InferenceCrowd.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/InferenceCrowd.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/InferenceCrowd.java
 Thu Jul 12 08:58:05 2012
@@ -21,9 +21,11 @@ package org.apache.uima.textmarker.visit
 
 import java.util.List;
 
+import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.textmarker.ScriptApply;
 import org.apache.uima.textmarker.TextMarkerElement;
 import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.rule.RuleMatch;
 
 
 public class InferenceCrowd implements TextMarkerInferenceVisitor {
@@ -57,4 +59,11 @@ public class InferenceCrowd implements T
     finished(stream);
   }
 
+  public void annotationAdded(AnnotationFS annotation, RuleMatch creator) {
+    for (TextMarkerInferenceVisitor each : visitors) {
+      each.annotationAdded(annotation, creator);
+    }
+    
+  }
+
 }

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/StatisticsVisitor.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/StatisticsVisitor.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/StatisticsVisitor.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/StatisticsVisitor.java
 Thu Jul 12 08:58:05 2012
@@ -27,6 +27,7 @@ import java.util.Map;
 import org.apache.uima.cas.Feature;
 import org.apache.uima.cas.FeatureStructure;
 import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.jcas.cas.DoubleArray;
 import org.apache.uima.jcas.cas.IntegerArray;
@@ -36,6 +37,7 @@ import org.apache.uima.textmarker.TextMa
 import org.apache.uima.textmarker.TextMarkerStream;
 import org.apache.uima.textmarker.action.AbstractTextMarkerAction;
 import org.apache.uima.textmarker.condition.AbstractTextMarkerCondition;
+import org.apache.uima.textmarker.rule.RuleMatch;
 import org.apache.uima.textmarker.type.Statistics;
 import org.apache.uima.textmarker.utils.UIMAUtils;
 import org.apache.uima.textmarker.verbalize.TextMarkerVerbalizer;
@@ -196,4 +198,7 @@ public class StatisticsVisitor implement
     return actionAmount;
   }
 
+  public void annotationAdded(AnnotationFS annotation, RuleMatch creator) {
+  }
+
 }

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/TextMarkerInferenceVisitor.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/TextMarkerInferenceVisitor.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/TextMarkerInferenceVisitor.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/TextMarkerInferenceVisitor.java
 Thu Jul 12 08:58:05 2012
@@ -21,9 +21,11 @@ package org.apache.uima.textmarker.visit
 
 import java.util.List;
 
+import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.textmarker.ScriptApply;
 import org.apache.uima.textmarker.TextMarkerElement;
 import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.rule.RuleMatch;
 
 
 public interface TextMarkerInferenceVisitor {
@@ -34,4 +36,6 @@ public interface TextMarkerInferenceVisi
 
   void finished(TextMarkerStream stream, List<TextMarkerInferenceVisitor> 
visitors);
 
+  void annotationAdded(AnnotationFS annotation, RuleMatch creator);
+  
 }

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/TimeProfilerVisitor.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/TimeProfilerVisitor.java?rev=1360586&r1=1360585&r2=1360586&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/TimeProfilerVisitor.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/visitor/TimeProfilerVisitor.java
 Thu Jul 12 08:58:05 2012
@@ -23,9 +23,11 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.textmarker.ScriptApply;
 import org.apache.uima.textmarker.TextMarkerElement;
 import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.rule.RuleMatch;
 
 
 public class TimeProfilerVisitor implements TextMarkerInferenceVisitor {
@@ -55,4 +57,7 @@ public class TimeProfilerVisitor impleme
     return timeInfo;
   }
 
+  public void annotationAdded(AnnotationFS annotation, RuleMatch creator) {
+  }
+
 }


Reply via email to