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 2016/01/04 11:33:50 UTC

svn commit: r1722834 [3/9] - in /uima/ruta/trunk: ./ example-projects/ruta-ep-example-extensions/ example-projects/ruta-ep-example-extensions/src/main/java/org/apache/uima/ruta/example/extensions/ ruta-core-ext/src/main/java/org/apache/uima/ruta/block/...

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ClearAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ClearAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ClearAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ClearAction.java Mon Jan  4 10:33:48 2016
@@ -20,8 +20,8 @@
 package org.apache.uima.ruta.action;
 
 import org.apache.uima.ruta.RutaStream;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
-import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class ClearAction extends AbstractRutaAction {
@@ -34,7 +34,8 @@ public class ClearAction extends Abstrac
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleElement element = context.getElement();
     element.getParent().getEnvironment().setVariableValue(list, null);
   }
 

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ColorAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ColorAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ColorAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ColorAction.java Mon Jan  4 10:33:48 2016
@@ -21,15 +21,14 @@ package org.apache.uima.ruta.action;
 
 import org.apache.uima.cas.FeatureStructure;
 import org.apache.uima.cas.Type;
-import org.apache.uima.ruta.RutaBlock;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.bool.IBooleanExpression;
 import org.apache.uima.ruta.expression.bool.SimpleBooleanExpression;
 import org.apache.uima.ruta.expression.string.IStringExpression;
 import org.apache.uima.ruta.expression.string.SimpleStringExpression;
-import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.expression.type.ITypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
-import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.type.RutaColoring;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
@@ -41,9 +40,9 @@ public class ColorAction extends Abstrac
 
   private IBooleanExpression selected;
 
-  private TypeExpression type;
+  private ITypeExpression type;
 
-  public ColorAction(TypeExpression type, IStringExpression bgcolor, IStringExpression fgcolor,
+  public ColorAction(ITypeExpression type, IStringExpression bgcolor, IStringExpression fgcolor,
           IBooleanExpression selected) {
     super();
     this.type = type;
@@ -53,17 +52,18 @@ public class ColorAction extends Abstrac
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleElement element = context.getElement();
     Type casType = stream.getJCas().getCasType(RutaColoring.type);
     FeatureStructure newAnnotationFS = stream.getCas().createFS(casType);
     RutaColoring coloring = null;
     if (newAnnotationFS instanceof RutaColoring) {
       coloring = (RutaColoring) newAnnotationFS;
-      RutaBlock parent = element.getParent();
-      coloring.setBgColor(bgcolor.getStringValue(parent, match, element, stream));
-      coloring.setFgColor(fgcolor.getStringValue(parent, match, element, stream));
-      coloring.setSelected(selected.getBooleanValue(parent, match, element, stream));
-      coloring.setTargetType(type.getType(parent).getName());
+      element.getParent();
+      coloring.setBgColor(bgcolor.getStringValue(context, stream));
+      coloring.setFgColor(fgcolor.getStringValue(context, stream));
+      coloring.setSelected(selected.getBooleanValue(context, stream));
+      coloring.setTargetType(type.getType(context, stream).getName());
       coloring.addToIndexes();
     }
   }
@@ -80,7 +80,7 @@ public class ColorAction extends Abstrac
     return selected;
   }
 
-  public TypeExpression getType() {
+  public ITypeExpression getType() {
     return type;
   }
 

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ComposedAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ComposedAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ComposedAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ComposedAction.java Mon Jan  4 10:33:48 2016
@@ -22,8 +22,7 @@ package org.apache.uima.ruta.action;
 import java.util.List;
 
 import org.apache.uima.ruta.RutaStream;
-import org.apache.uima.ruta.rule.RuleElement;
-import org.apache.uima.ruta.rule.RuleMatch;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class ComposedAction extends AbstractRutaAction {
@@ -36,10 +35,10 @@ public class ComposedAction extends Abst
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
     for (AbstractRutaAction each : actions) {
       crowd.beginVisit(each, null);
-      each.execute(match, element, stream, crowd);
+      each.execute(context, stream, crowd);
       crowd.endVisit(each, null);
     }
   }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ConfigureAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ConfigureAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ConfigureAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ConfigureAction.java Mon Jan  4 10:33:48 2016
@@ -41,9 +41,9 @@ import org.apache.uima.ruta.expression.l
 import org.apache.uima.ruta.expression.list.TypeListExpression;
 import org.apache.uima.ruta.expression.number.INumberExpression;
 import org.apache.uima.ruta.expression.string.IStringExpression;
-import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.expression.type.ITypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
-import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class ConfigureAction extends AbstractRutaAction {
@@ -59,7 +59,8 @@ public class ConfigureAction extends Abs
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleElement element = context.getElement();
     RutaBlock parent = element.getParent();
     RutaModule thisScript = parent.getScript();
     AnalysisEngine targetEngine = thisScript.getEngine(namespace);
@@ -69,7 +70,7 @@ public class ConfigureAction extends Abs
     Set<Entry<IStringExpression, IRutaExpression>> entrySet = parameterMap.entrySet();
     for (Entry<IStringExpression, IRutaExpression> entry : entrySet) {
       IStringExpression key = entry.getKey();
-      String stringValue = key.getStringValue(parent, match, element, stream);
+      String stringValue = key.getStringValue(context, stream);
       ConfigurationParameter configurationParameter = configurationParameterDeclarations
               .getConfigurationParameter(null, stringValue);
       if (configurationParameter != null) {
@@ -79,11 +80,11 @@ public class ConfigureAction extends Abs
           if (configurationParameter.isMultiValued()) {
             if (value instanceof StringListExpression) {
               StringListExpression sle = (StringListExpression) value;
-              List<String> list = sle.getList(parent, stream);
+              List<String> list = sle.getList(context, stream);
               targetEngine.setConfigParameterValue(stringValue, list.toArray(new String[0]));
             } else if (value instanceof TypeListExpression) {
               TypeListExpression tle = (TypeListExpression) value;
-              List<Type> list = tle.getList(parent, stream);
+              List<Type> list = tle.getList(context, stream);
               List<String> stringList = new ArrayList<String>();
               for (Type each : list) {
                 stringList.add(each.getName());
@@ -93,18 +94,18 @@ public class ConfigureAction extends Abs
           } else {
             if (value instanceof IStringExpression) {
               IStringExpression se = (IStringExpression) value;
-              String string = se.getStringValue(parent, match, element, stream);
+              String string = se.getStringValue(context, stream);
               targetEngine.setConfigParameterValue(stringValue, string);
-            } else if (value instanceof TypeExpression) {
-              TypeExpression te = (TypeExpression) value;
-              Type t = te.getType(parent);
+            } else if (value instanceof ITypeExpression) {
+              ITypeExpression te = (ITypeExpression) value;
+              Type t = te.getType(context, stream);
               targetEngine.setConfigParameterValue(stringValue, t.getName());
             }
           }
         } else if (type.equals("Float")) {
           if (value instanceof NumberListExpression) {
             NumberListExpression nle = (NumberListExpression) value;
-            List<Number> list = nle.getList(parent, stream);
+            List<Number> list = nle.getList(context, stream);
             List<Float> numbers = new ArrayList<Float>();
             for (Number number : list) {
               numbers.add(number.floatValue());
@@ -113,14 +114,14 @@ public class ConfigureAction extends Abs
           } else {
             if (value instanceof INumberExpression) {
               INumberExpression ne = (INumberExpression) value;
-              Double d = ne.getDoubleValue(parent, match, element, stream);
+              Double d = ne.getDoubleValue(context, stream);
               targetEngine.setConfigParameterValue(stringValue, d.floatValue());
             }
           }
         } else if (type.equals("Integer")) {
           if (value instanceof NumberListExpression) {
             NumberListExpression nle = (NumberListExpression) value;
-            List<Number> list = nle.getList(parent, stream);
+            List<Number> list = nle.getList(context, stream);
             List<Integer> numbers = new ArrayList<Integer>();
             for (Number number : list) {
               numbers.add(number.intValue());
@@ -129,19 +130,19 @@ public class ConfigureAction extends Abs
           } else {
             if (value instanceof INumberExpression) {
               INumberExpression ne = (INumberExpression) value;
-              Integer i = ne.getIntegerValue(parent, match, element, stream);
+              Integer i = ne.getIntegerValue(context, stream);
               targetEngine.setConfigParameterValue(stringValue, i);
             }
           }
         } else if (type.equals("Boolean")) {
           if (value instanceof BooleanListExpression) {
             BooleanListExpression ble = (BooleanListExpression) value;
-            List<Boolean> list = ble.getList(parent, stream);
+            List<Boolean> list = ble.getList(context, stream);
             targetEngine.setConfigParameterValue(stringValue, list.toArray());
           } else {
             if (value instanceof IBooleanExpression) {
               IBooleanExpression be = (IBooleanExpression) value;
-              Boolean b = be.getBooleanValue(parent, match, element, stream);
+              Boolean b = be.getBooleanValue(context, stream);
               targetEngine.setConfigParameterValue(stringValue, b);
             }
           }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/CreateAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/CreateAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/CreateAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/CreateAction.java Mon Jan  4 10:33:48 2016
@@ -19,35 +19,33 @@
 
 package org.apache.uima.ruta.action;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.uima.cas.FeatureStructure;
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.jcas.cas.TOP;
 import org.apache.uima.jcas.tcas.Annotation;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.IRutaExpression;
 import org.apache.uima.ruta.expression.number.INumberExpression;
 import org.apache.uima.ruta.expression.string.IStringExpression;
-import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.expression.type.ITypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class CreateAction extends AbstractStructureAction {
 
-  private TypeExpression structureType;
+  private ITypeExpression structureType;
 
   private Map<IStringExpression, IRutaExpression> features;
 
   private List<INumberExpression> indexes;
 
-  public CreateAction(TypeExpression structureType, Map<IStringExpression, IRutaExpression> features,
-          List<INumberExpression> indexes) {
+  public CreateAction(ITypeExpression structureType,
+          Map<IStringExpression, IRutaExpression> features, List<INumberExpression> indexes) {
     super();
     this.structureType = structureType;
     this.features = features == null ? new HashMap<IStringExpression, IRutaExpression>() : features;
@@ -55,8 +53,10 @@ public class CreateAction extends Abstra
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
-    List<Integer> indexList = getIndexList(match, element, stream);
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
+    List<Integer> indexList = getIndexList(indexes, context, stream);
     List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(indexList,
             element.getContainer());
     for (AnnotationFS matchedAnnotation : matchedAnnotations) {
@@ -64,44 +64,20 @@ public class CreateAction extends Abstra
       if (matchedAnnotation == null) {
         return;
       }
-      Type type = structureType.getType(element.getParent());
-      FeatureStructure newFS = stream.getCas().createFS(type);
-      if (newFS instanceof Annotation) {
-        Annotation a = (Annotation) newFS;
+      Type type = structureType.getType(context, stream);
+      AnnotationFS annotation = stream.getCas().createAnnotation(type, 0, 0);
+      if (annotation instanceof Annotation) {
+        Annotation a = (Annotation) annotation;
         a.setBegin(matchedAnnotation.getBegin());
         a.setEnd(matchedAnnotation.getEnd());
-        stream.addAnnotation(a, match);
+        context.setAnnotation(matchedAnnotation);
+        stream.assignFeatureValues(annotation, features, context);
+        stream.addAnnotation(a, true, match);
       }
-      TOP newStructure = null;
-      if (newFS instanceof TOP) {
-        newStructure = (TOP) newFS;
-        fillFeatures(newStructure, features, matchedAnnotation, element, stream);
-        newStructure.addToIndexes();
-      }
-    }
-  }
-
-  // TODO refactor duplicate methods -> MarkAction
-  protected List<Integer> getIndexList(RuleMatch match, RuleElement element, RutaStream stream) {
-    List<Integer> indexList = new ArrayList<Integer>();
-    if (indexes == null || indexes.isEmpty()) {
-      int self = element.getContainer().getRuleElements().indexOf(element) + 1;
-      indexList.add(self);
-      return indexList;
-    }
-    int last = Integer.MAX_VALUE - 1;
-    for (INumberExpression each : indexes) {
-      // no feature matches allowed
-      int value = each.getIntegerValue(element.getParent(), null, stream);
-      for (int i = Math.min(value, last + 1); i < value; i++) {
-        indexList.add(i);
-      }
-      indexList.add(value);
     }
-    return indexList;
   }
 
-  public TypeExpression getStructureType() {
+  public ITypeExpression getStructureType() {
     return structureType;
   }
 

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/DelAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/DelAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/DelAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/DelAction.java Mon Jan  4 10:33:48 2016
@@ -23,6 +23,7 @@ import java.util.List;
 
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.ruta.RutaStream;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.type.RutaBasic;
@@ -35,7 +36,9 @@ public class DelAction extends AbstractR
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
     List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOfElement(element);
     for (AnnotationFS annotationFS : matchedAnnotationsOf) {
       List<RutaBasic> basicsInWindow = stream.getBasicsInWindow(annotationFS);

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/DynamicAnchoringAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/DynamicAnchoringAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/DynamicAnchoringAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/DynamicAnchoringAction.java Mon Jan  4 10:33:48 2016
@@ -19,12 +19,10 @@
 
 package org.apache.uima.ruta.action;
 
-import org.apache.uima.ruta.RutaBlock;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.bool.IBooleanExpression;
 import org.apache.uima.ruta.expression.number.INumberExpression;
-import org.apache.uima.ruta.rule.RuleElement;
-import org.apache.uima.ruta.rule.RuleMatch;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class DynamicAnchoringAction extends AbstractRutaAction {
@@ -44,16 +42,16 @@ public class DynamicAnchoringAction exte
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
-    RutaBlock parent = element.getParent();
-    boolean activated = active.getBooleanValue(parent, match, element, stream);
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    context.getElement();
+    boolean activated = active.getBooleanValue(context, stream);
     stream.setDynamicAnchoring(activated);
     if (panelty != null) {
-      double p = panelty.getDoubleValue(parent, match, element, stream);
+      double p = panelty.getDoubleValue(context, stream);
       stream.setIndexPenalty(p);
     }
     if (factor != null) {
-      double f = factor.getDoubleValue(parent, match, element, stream);
+      double f = factor.getDoubleValue(context, stream);
       stream.setAnchoringFactor(f);
     }
   }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ExecAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ExecAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ExecAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ExecAction.java Mon Jan  4 10:33:48 2016
@@ -39,8 +39,7 @@ import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.ScriptApply;
 import org.apache.uima.ruta.expression.list.TypeListExpression;
 import org.apache.uima.ruta.expression.string.IStringExpression;
-import org.apache.uima.ruta.rule.RuleElement;
-import org.apache.uima.ruta.rule.RuleMatch;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 import org.apache.uima.util.XMLInputSource;
 
@@ -61,19 +60,19 @@ public class ExecAction extends CallActi
   }
 
   @Override
-  protected void callScript(RutaBlock block, RuleMatch match, RuleElement element,
-          RutaStream stream, InferenceCrowd crowd) {
+  protected void callScript(RutaBlock block, MatchContext context, RutaStream stream,
+          InferenceCrowd crowd) {
     ScriptApply apply = block.apply(stream, crowd);
-    match.addDelegateApply(this, apply);
+    context.getRuleMatch().addDelegateApply(this, apply);
   }
 
   @Override
-  protected void callEngine(RuleMatch match, InferenceCrowd crowd, AnalysisEngine targetEngine,
-          RuleElement element, RutaStream stream) throws ResourceInitializationException,
+  protected void callEngine(MatchContext context, InferenceCrowd crowd,
+          AnalysisEngine targetEngine, RutaStream stream) throws ResourceInitializationException,
           AnalysisEngineProcessException {
     CAS cas = stream.getCas();
     if (view != null) {
-      String viewName = view.getStringValue(element.getParent(), match, element, stream);
+      String viewName = view.getStringValue(context, stream);
       if (!viewName.equals(CAS.NAME_DEFAULT_SOFA)) {
         cas = cas.getView(viewName);
         AnalysisEngineMetaData metaData = targetEngine.getAnalysisEngineMetaData();
@@ -93,7 +92,7 @@ public class ExecAction extends CallActi
     targetEngine.process(cas);
 
     if (typeList != null && view == null) {
-      List<Type> list = typeList.getList(element.getParent(), stream);
+      List<Type> list = typeList.getList(context, stream);
       for (Type type : list) {
         AnnotationIndex<AnnotationFS> ai = cas.getAnnotationIndex(type);
         Collection<AnnotationFS> toUpdate = new LinkedList<AnnotationFS>();
@@ -104,12 +103,11 @@ public class ExecAction extends CallActi
           stream.removeAnnotation(each);
         }
         for (AnnotationFS each : toUpdate) {
-          stream.addAnnotation(each, true, match);
+          stream.addAnnotation(each, true, context.getRuleMatch());
         }
       }
     }
-    
-    
+
   }
 
   public TypeListExpression getTypeList() {

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FillAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FillAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FillAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FillAction.java Mon Jan  4 10:33:48 2016
@@ -24,11 +24,11 @@ import java.util.Map;
 
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.jcas.tcas.Annotation;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.IRutaExpression;
 import org.apache.uima.ruta.expression.string.IStringExpression;
-import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.expression.type.ITypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
@@ -37,22 +37,24 @@ public class FillAction extends Abstract
 
   private Map<IStringExpression, IRutaExpression> features;
 
-  private TypeExpression structureType;
+  private ITypeExpression structureType;
 
-  public FillAction(TypeExpression structureType, Map<IStringExpression, IRutaExpression> features) {
+  public FillAction(ITypeExpression structureType, Map<IStringExpression, IRutaExpression> features) {
     super();
     this.structureType = structureType;
     this.features = features;
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
     List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotationsOfElement(element);
     for (AnnotationFS matchedAnnotation : matchedAnnotations) {
       if (matchedAnnotation == null) {
         return;
       }
-      Type type = getStructureType().getType(element.getParent());
+      Type type = getStructureType().getType(context, stream);
       List<AnnotationFS> list = stream.getAnnotationsInWindow(matchedAnnotation, type);
       if (list.isEmpty()) {
         list = stream.getOverappingAnnotations(matchedAnnotation, type);
@@ -72,7 +74,8 @@ public class FillAction extends Abstract
       if (!list.isEmpty()) {
         AnnotationFS annotationFS = list.get(0);
         stream.getCas().removeFsFromIndexes(annotationFS);
-        fillFeatures((Annotation) annotationFS, features, matchedAnnotation, element, stream);
+        context.setAnnotation(matchedAnnotation);
+        stream.assignFeatureValues(annotationFS, features, context);
         stream.getCas().addFsToIndexes(annotationFS);
       }
     }
@@ -83,7 +86,7 @@ public class FillAction extends Abstract
     return features;
   }
 
-  public TypeExpression getStructureType() {
+  public ITypeExpression getStructureType() {
     return structureType;
   }
 

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FilterTypeAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FilterTypeAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FilterTypeAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FilterTypeAction.java Mon Jan  4 10:33:48 2016
@@ -24,31 +24,32 @@ import java.util.List;
 
 import org.apache.uima.cas.Type;
 import org.apache.uima.ruta.RutaStream;
-import org.apache.uima.ruta.expression.type.TypeExpression;
-import org.apache.uima.ruta.rule.RuleElement;
-import org.apache.uima.ruta.rule.RuleMatch;
+import org.apache.uima.ruta.expression.type.ITypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class FilterTypeAction extends AbstractRutaAction {
 
-  public List<TypeExpression> getList() {
-    return list;
-  }
-
-  private List<TypeExpression> list;
 
-  public FilterTypeAction(List<TypeExpression> list) {
+  public FilterTypeAction(List<ITypeExpression> list) {
     super();
     this.list = list;
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    context.getElement();
     List<Type> types = new ArrayList<Type>();
-    for (TypeExpression each : list) {
-      types.add(each.getType(element.getParent()));
+    for (ITypeExpression each : list) {
+      types.add(each.getType(context, stream));
     }
     stream.filterTypes(types);
   }
 
+  public List<ITypeExpression> getList() {
+    return list;
+  }
+  
+  private List<ITypeExpression> list;
+
 }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GatherAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GatherAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GatherAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GatherAction.java Mon Jan  4 10:33:48 2016
@@ -37,13 +37,13 @@ import org.apache.uima.jcas.JCas;
 import org.apache.uima.jcas.cas.FSArray;
 import org.apache.uima.jcas.cas.TOP;
 import org.apache.uima.jcas.tcas.Annotation;
-import org.apache.uima.ruta.RutaBlock;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.IRutaExpression;
 import org.apache.uima.ruta.expression.list.NumberListExpression;
 import org.apache.uima.ruta.expression.number.INumberExpression;
 import org.apache.uima.ruta.expression.string.IStringExpression;
-import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.expression.type.ITypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleElementMatch;
 import org.apache.uima.ruta.rule.RuleMatch;
@@ -53,13 +53,13 @@ import org.apache.uima.ruta.visitor.Infe
 
 public class GatherAction extends AbstractStructureAction {
 
-  private TypeExpression structureType;
+  private ITypeExpression structureType;
 
   private Map<IStringExpression, IRutaExpression> features;
 
   private List<INumberExpression> indexes;
 
-  public GatherAction(TypeExpression structureType,
+  public GatherAction(ITypeExpression structureType,
           Map<IStringExpression, IRutaExpression> features, List<INumberExpression> indexes) {
     super();
     this.structureType = structureType;
@@ -68,15 +68,17 @@ public class GatherAction extends Abstra
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
-    List<Integer> indexList = getIndexList(match, element, stream);
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
+    List<Integer> indexList = getIndexList(indexes, context, stream);
     List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(indexList,
             element.getContainer());
     for (AnnotationFS matchedAnnotation : matchedAnnotations) {
       if (matchedAnnotation == null) {
         return;
       }
-      Type type = structureType.getType(element.getParent());
+      Type type = structureType.getType(context, stream);
       FeatureStructure newFS = stream.getCas().createFS(type);
       if (newFS instanceof Annotation) {
         Annotation a = (Annotation) newFS;
@@ -87,7 +89,7 @@ public class GatherAction extends Abstra
       TOP newStructure = null;
       if (newFS instanceof TOP) {
         newStructure = (TOP) newFS;
-        gatherFeatures(newStructure, features, matchedAnnotation, element, match, stream);
+        gatherFeatures(newStructure, features, matchedAnnotation, context, stream);
         newStructure.addToIndexes();
       }
     }
@@ -95,20 +97,20 @@ public class GatherAction extends Abstra
   }
 
   private void gatherFeatures(TOP structure, Map<IStringExpression, IRutaExpression> features,
-          AnnotationFS matchedAnnotation, RuleElement element, RuleMatch match, RutaStream stream) {
+          AnnotationFS matchedAnnotation, MatchContext context, RutaStream stream) {
     Map<String, List<Number>> map = new HashMap<String, List<Number>>();
     for (Entry<IStringExpression, IRutaExpression> each : features.entrySet()) {
-      RutaBlock parent = element.getParent();
-      String value = each.getKey().getStringValue(parent, match, element, stream);
+      context.getParent();
+      String value = each.getKey().getStringValue(context, stream);
       IRutaExpression expr = each.getValue();
       List<Number> ints = new ArrayList<Number>();
       if (expr instanceof INumberExpression) {
         INumberExpression ne = (INumberExpression) expr;
-        ints.add(ne.getIntegerValue(parent, match, element, stream));
+        ints.add(ne.getIntegerValue(context, stream));
         map.put(value, ints);
       } else if (expr instanceof NumberListExpression) {
         NumberListExpression ne = (NumberListExpression) expr;
-        map.put(value, ne.getList(parent, stream));
+        map.put(value, ne.getList(context, stream));
       }
     }
 
@@ -123,7 +125,8 @@ public class GatherAction extends Abstra
       if (reIndexes != null && !reIndexes.isEmpty()) {
         Type range = targetFeature.getRange();
 
-        List<RuleElementMatch> tms = getMatchInfo(match, element, reIndexes);
+        List<RuleElementMatch> tms = getMatchInfo(context.getRuleMatch(), context.getElement(),
+                reIndexes);
         if (tms.size() == 0) {// do nothing
 
         } else if (tms.size() == 1) {
@@ -206,27 +209,8 @@ public class GatherAction extends Abstra
     return result;
   }
 
-  // TODO refactor duplicate methods -> MarkAction
-  protected List<Integer> getIndexList(RuleMatch match, RuleElement element, RutaStream stream) {
-    List<Integer> indexList = new ArrayList<Integer>();
-    if (indexes == null || indexes.isEmpty()) {
-      int self = element.getContainer().getRuleElements().indexOf(element) + 1;
-      indexList.add(self);
-      return indexList;
-    }
-    int last = Integer.MAX_VALUE - 1;
-    for (INumberExpression each : indexes) {
-      // no feature matches allowed
-      int value = each.getIntegerValue(element.getParent(), null, stream);
-      for (int i = Math.min(value, last + 1); i < value; i++) {
-        indexList.add(i);
-      }
-      indexList.add(value);
-    }
-    return indexList;
-  }
 
-  public TypeExpression getStructureType() {
+  public ITypeExpression getStructureType() {
     return structureType;
   }
 

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetAction.java Mon Jan  4 10:33:48 2016
@@ -27,8 +27,8 @@ import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.IRutaExpression;
 import org.apache.uima.ruta.expression.list.ListExpression;
 import org.apache.uima.ruta.expression.string.IStringExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
-import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class GetAction extends AbstractRutaAction {
@@ -47,10 +47,12 @@ public class GetAction extends AbstractR
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    context.getRuleMatch();
+    RuleElement element = context.getElement();
     RutaBlock parent = element.getParent();
-    String op = opExpr.getStringValue(parent, match, element, stream);
-    List<?> list = listExpr.getList(parent, stream);
+    String op = opExpr.getStringValue(context, stream);
+    List<?> list = listExpr.getList(context, stream);
     if ("dominant".equals(op)) {
       parent.getEnvironment().setVariableValue(var, getDominant(list, parent));
     }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetFeatureAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetFeatureAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetFeatureAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetFeatureAction.java Mon Jan  4 10:33:48 2016
@@ -30,6 +30,7 @@ import org.apache.uima.ruta.RutaEnvironm
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.UIMAConstants;
 import org.apache.uima.ruta.expression.string.IStringExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.rule.RutaRuleElement;
@@ -48,7 +49,9 @@ public class GetFeatureAction extends Ab
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
     List<Type> types = new ArrayList<Type>();
     RutaBlock parent = element.getParent();
     if (element instanceof RutaRuleElement) {
@@ -58,7 +61,7 @@ public class GetFeatureAction extends Ab
       return;
 
     for (Type type : types) {
-      String stringValue = featureStringExpression.getStringValue(parent, match, element, stream);
+      String stringValue = featureStringExpression.getStringValue(context, stream);
       Feature featureByBaseName = type.getFeatureByBaseName(stringValue);
       RutaEnvironment environment = parent.getEnvironment();
       List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotationsOfElement(element);

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetListAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetListAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetListAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetListAction.java Mon Jan  4 10:33:48 2016
@@ -30,6 +30,7 @@ import org.apache.uima.cas.text.Annotati
 import org.apache.uima.ruta.RutaBlock;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.string.IStringExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.type.RutaBasic;
@@ -53,10 +54,13 @@ public class GetListAction extends Abstr
     this.opExpr = op;
   }
 
+  @SuppressWarnings("unchecked")
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
     RutaBlock parent = element.getParent();
-    String op = opExpr.getStringValue(parent, match, element, stream);
+    String op = opExpr.getStringValue(context, stream);
     List<Type> list = new ArrayList<Type>();
 
     int indexOf = element.getContainer().getRuleElements().indexOf(element);
@@ -71,7 +75,7 @@ public class GetListAction extends Abstr
         Collection<?>[] beginMap = beginAnchor.getBeginMap();
         Set<AnnotationFS> aset = new HashSet<AnnotationFS>();
         for (Collection<?> set : beginMap) {
-          if(set != null) {
+          if (set != null) {
             aset.addAll((Collection<? extends AnnotationFS>) set);
           }
         }
@@ -80,11 +84,11 @@ public class GetListAction extends Abstr
         }
       } else if (TYPES_AT_END.equals(op)) {
         RutaBasic endAnchor = stream.getEndAnchor(matched.getEnd());
-//        Collection<Set<AnnotationFS>> values = endAnchor.getEndMap().values();
+        // Collection<Set<AnnotationFS>> values = endAnchor.getEndMap().values();
         Collection<?>[] endMap = endAnchor.getEndMap();
         Set<AnnotationFS> aset = new HashSet<AnnotationFS>();
         for (Collection<?> set : endMap) {
-          if(set != null) {
+          if (set != null) {
             aset.addAll((Collection<? extends AnnotationFS>) set);
           }
         }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GreedyAnchoringAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GreedyAnchoringAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GreedyAnchoringAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GreedyAnchoringAction.java Mon Jan  4 10:33:48 2016
@@ -19,12 +19,11 @@
 
 package org.apache.uima.ruta.action;
 
-import org.apache.uima.ruta.RutaBlock;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.bool.IBooleanExpression;
 import org.apache.uima.ruta.expression.bool.SimpleBooleanExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
-import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class GreedyAnchoringAction extends AbstractRutaAction {
@@ -32,7 +31,7 @@ public class GreedyAnchoringAction exten
   private final IBooleanExpression greedyRuleElement;
 
   private final IBooleanExpression greedyRule;
-  
+
   public GreedyAnchoringAction(IBooleanExpression active, IBooleanExpression active2) {
     super();
     this.greedyRuleElement = active;
@@ -40,10 +39,12 @@ public class GreedyAnchoringAction exten
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
-    RutaBlock parent = element.getParent();
-    boolean greedy1 = greedyRuleElement.getBooleanValue(parent, match, element, stream);
-    boolean greedy2 = greedyRule.getBooleanValue(parent, match, element, stream);
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    context.getRuleMatch();
+    RuleElement element = context.getElement();
+    element.getParent();
+    boolean greedy1 = greedyRuleElement.getBooleanValue(context, stream);
+    boolean greedy2 = greedyRule.getBooleanValue(context, stream);
     stream.setGreedyRuleElement(greedy1);
     stream.setGreedyRule(greedy2);
   }
@@ -56,6 +57,4 @@ public class GreedyAnchoringAction exten
     return greedyRule;
   }
 
-  
-
 }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ImplicitFeatureAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ImplicitFeatureAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ImplicitFeatureAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ImplicitFeatureAction.java Mon Jan  4 10:33:48 2016
@@ -31,21 +31,13 @@ import org.apache.uima.cas.Type;
 import org.apache.uima.cas.TypeSystem;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.ruta.RutaStream;
-import org.apache.uima.ruta.UIMAConstants;
 import org.apache.uima.ruta.expression.IRutaExpression;
-import org.apache.uima.ruta.expression.bool.IBooleanExpression;
-import org.apache.uima.ruta.expression.feature.FeatureExpression;
 import org.apache.uima.ruta.expression.feature.FeatureMatchExpression;
-import org.apache.uima.ruta.expression.feature.GenericFeatureExpression;
-import org.apache.uima.ruta.expression.feature.SimpleFeatureExpression;
-import org.apache.uima.ruta.expression.number.INumberExpression;
-import org.apache.uima.ruta.expression.string.IStringExpression;
 import org.apache.uima.ruta.expression.type.ITypeExpression;
-import org.apache.uima.ruta.expression.type.TypeExpression;
 import org.apache.uima.ruta.rule.AnnotationComparator;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
-import org.apache.uima.ruta.utils.UIMAUtils;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class ImplicitFeatureAction extends AbstractRutaAction {
@@ -60,9 +52,11 @@ public class ImplicitFeatureAction exten
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
-    TypeExpression typeExpr = expr.getTypeExpr(element.getParent());
-    Type type = typeExpr.getType(element.getParent());
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
+    ITypeExpression typeExpr = expr.getTypeExpr(context, stream);
+    Type type = typeExpr.getType(context, stream);
     List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotationsOfElement(element);
     Collection<AnnotationFS> annotations = new TreeSet<AnnotationFS>(comp);
     for (AnnotationFS annotation : matchedAnnotations) {
@@ -72,95 +66,21 @@ public class ImplicitFeatureAction exten
       stream.getCas().removeFsFromIndexes(each);
     }
     Collection<AnnotationFS> featureAnnotations = expr.getFeatureAnnotations(annotations, stream,
-            element.getParent(), false);
+            context, false);
     if (featureAnnotations.isEmpty()) {
       // null value in feature, but we require the host
       featureAnnotations = annotations;
     }
-    Feature feature = expr.getFeature(element.getParent());
+    Feature feature = expr.getFeature(context, stream);
     IRutaExpression arg = expr.getArg();
     for (AnnotationFS each : featureAnnotations) {
-      setFeatureValue(each, feature, arg, element, stream);
+      stream.assignFeatureValue(each, feature, arg, context);
     }
     for (AnnotationFS each : annotations) {
       stream.getCas().addFsToIndexes(each);
     }
   }
 
-  private void setFeatureValue(AnnotationFS a, Feature feature, IRutaExpression argExpr,
-          RuleElement element, RutaStream stream) {
-    if (feature == null) {
-      throw new IllegalArgumentException("Not able to assign feature value (e.g., coveredText).");
-    }
-    String range = feature.getRange().getName();
-    if (range.equals(UIMAConstants.TYPE_STRING)) {
-      if (argExpr instanceof IStringExpression) {
-        IStringExpression stringExpr = (IStringExpression) argExpr;
-        String string = stringExpr.getStringValue(element.getParent(), a, stream);
-        a.setStringValue(feature, string);
-      }
-    } else if (argExpr instanceof INumberExpression
-            && (range.equals(UIMAConstants.TYPE_INTEGER) || range.equals(UIMAConstants.TYPE_LONG)
-                    || range.equals(UIMAConstants.TYPE_SHORT) || range
-                      .equals(UIMAConstants.TYPE_BYTE))) {
-      INumberExpression numberExpr = (INumberExpression) argExpr;
-      int v = numberExpr.getIntegerValue(element.getParent(), a, stream);
-      a.setIntValue(feature, v);
-    } else if (argExpr instanceof INumberExpression && (range.equals(UIMAConstants.TYPE_DOUBLE))) {
-      INumberExpression numberExpr = (INumberExpression) argExpr;
-      double v = numberExpr.getDoubleValue(element.getParent(), a, stream);
-      a.setDoubleValue(feature, v);
-    } else if (argExpr instanceof INumberExpression && (range.equals(UIMAConstants.TYPE_FLOAT))) {
-      INumberExpression numberExpr = (INumberExpression) argExpr;
-      float v = numberExpr.getFloatValue(element.getParent(), a, stream);
-      a.setFloatValue(feature, v);
-    } else if (argExpr instanceof IBooleanExpression && (range.equals(UIMAConstants.TYPE_BOOLEAN))) {
-      IBooleanExpression booleanExpr = (IBooleanExpression) argExpr;
-      boolean v = booleanExpr.getBooleanValue(element.getParent(), a, stream);
-      a.setBooleanValue(feature, v);
-    } else if (argExpr instanceof IBooleanExpression && (range.equals(UIMAConstants.TYPE_BOOLEAN))) {
-      IBooleanExpression booleanExpr = (IBooleanExpression) argExpr;
-      boolean v = booleanExpr.getBooleanValue(element.getParent(), a, stream);
-      a.setBooleanValue(feature, v);
-    } else if (argExpr instanceof ITypeExpression && !feature.getRange().isPrimitive()) {
-      ITypeExpression typeExpr = (ITypeExpression) argExpr;
-      Type t = typeExpr.getType(element.getParent());
-      List<AnnotationFS> inWindow = stream.getAnnotationsInWindow(a, t);
-      if (feature.getRange().isArray()) {
-        a.setFeatureValue(feature, UIMAUtils.toFSArray(stream.getJCas(), inWindow));
-      } else {
-        if (inWindow != null && !inWindow.isEmpty()) {
-          AnnotationFS annotation = inWindow.get(0);
-          a.setFeatureValue(feature, annotation);
-        } else {
-          a.setFeatureValue(feature, null);
-        }
-      }
-    } else if (argExpr instanceof GenericFeatureExpression && !feature.getRange().isPrimitive()) {
-      FeatureExpression fe = ((GenericFeatureExpression) argExpr).getFeatureExpression();
-      TypeExpression typeExpr = fe.getTypeExpr(element.getParent());
-      Type t = typeExpr.getType(element.getParent());
-      List<AnnotationFS> inWindow = stream.getAnnotationsInWindow(a, t);
-      if (fe instanceof SimpleFeatureExpression) {
-        SimpleFeatureExpression sfe = (SimpleFeatureExpression) fe;
-        List<AnnotationFS> featureAnnotations = new ArrayList<>(sfe.getFeatureAnnotations(inWindow,
-                stream, element.getParent(), false));
-        if (feature.getRange().isArray()) {
-          a.setFeatureValue(feature, UIMAUtils.toFSArray(stream.getJCas(), featureAnnotations));
-        } else if (!featureAnnotations.isEmpty()) {
-          AnnotationFS annotation = featureAnnotations.get(0);
-          a.setFeatureValue(feature, annotation);
-        }
-      } else {
-        if (feature.getRange().isArray()) {
-          a.setFeatureValue(feature, UIMAUtils.toFSArray(stream.getJCas(), inWindow));
-        } else {
-          AnnotationFS annotation = inWindow.get(0);
-          a.setFeatureValue(feature, annotation);
-        }
-      }
-    }
-  }
 
   private List<AnnotationFS> getAnnotations(AnnotationFS annotation, Type type,
           FeatureMatchExpression fme, RutaStream stream) {

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ImplicitMarkAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ImplicitMarkAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ImplicitMarkAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ImplicitMarkAction.java Mon Jan  4 10:33:48 2016
@@ -23,25 +23,28 @@ import java.util.List;
 
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.ruta.RutaStream;
-import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.expression.type.ITypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class ImplicitMarkAction extends AbstractMarkAction {
 
-  public ImplicitMarkAction(TypeExpression te) {
+  public ImplicitMarkAction(ITypeExpression te) {
     super(te);
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
     List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotationsOfElement(element);
     for (AnnotationFS matchedAnnotation : matchedAnnotations) {
       if (matchedAnnotation == null) {
         return;
       }
-      createAnnotation(matchedAnnotation, element, stream, match);
+      createAnnotation(matchedAnnotation, context, stream);
     }
 
   }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/LogAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/LogAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/LogAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/LogAction.java Mon Jan  4 10:33:48 2016
@@ -22,16 +22,14 @@ package org.apache.uima.ruta.action;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.apache.uima.ruta.RutaBlock;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.string.IStringExpression;
-import org.apache.uima.ruta.rule.RuleElement;
-import org.apache.uima.ruta.rule.RuleMatch;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class LogAction extends AbstractRutaAction {
 
-  public static final String LOGGER_NAME = Logger.global.getName();
+  public static final String LOGGER_NAME = Logger.getGlobal().getName();
 
   private final IStringExpression text;
 
@@ -44,9 +42,8 @@ public class LogAction extends AbstractR
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
-    RutaBlock parent = element.getParent();
-    String msg = text.getStringValue(parent, match, element, stream);
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    String msg = text.getStringValue(context, stream);
     Logger.getLogger(LOGGER_NAME).log(level, msg);
   }
 

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkAction.java Mon Jan  4 10:33:48 2016
@@ -26,7 +26,8 @@ import org.apache.uima.cas.text.Annotati
 import org.apache.uima.jcas.tcas.Annotation;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.number.INumberExpression;
-import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.expression.type.ITypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.type.RutaAnnotation;
@@ -38,15 +39,17 @@ public class MarkAction extends Abstract
 
   protected final List<INumberExpression> list;
 
-  public MarkAction(TypeExpression type, INumberExpression scoreValue, List<INumberExpression> list) {
+  public MarkAction(ITypeExpression type, INumberExpression scoreValue, List<INumberExpression> list) {
     super(type);
     this.score = scoreValue;
     this.list = list;
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
-    List<Integer> indexList = getIndexList(element, list, stream);
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
+    List<Integer> indexList = getIndexList(context, list, stream);
     List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(indexList,
             element.getContainer());
     for (AnnotationFS matchedAnnotation : matchedAnnotations) {
@@ -54,22 +57,22 @@ public class MarkAction extends Abstract
         return;
       }
       if (score == null) {
-        createAnnotation(matchedAnnotation, element, stream, match);
+        createAnnotation(matchedAnnotation, context, stream);
       } else {
-        double deltaScore = score.getDoubleValue(element.getParent(), match, element, stream);
-        updateHeuristicAnnotation(match, element, stream, matchedAnnotation, deltaScore);
+        double deltaScore = score.getDoubleValue(context, stream);
+        updateHeuristicAnnotation(context, stream, matchedAnnotation, deltaScore);
       }
     }
 
   }
 
-  protected void updateHeuristicAnnotation(RuleMatch match, RuleElement element, RutaStream stream,
+  protected void updateHeuristicAnnotation(MatchContext context, RutaStream stream,
           AnnotationFS matchedAnnotation, double deltaScore) {
     Type heuristicType = stream.getJCas().getCasType(RutaAnnotation.type);
     RutaAnnotation heuristicAnnotation = (RutaAnnotation) stream.getCas().createAnnotation(
             heuristicType, matchedAnnotation.getBegin(), matchedAnnotation.getEnd());
     Annotation newAnnotation = (Annotation) stream.getCas().createAnnotation(
-            type.getType(element.getParent()), heuristicAnnotation.getBegin(),
+            type.getType(context, stream), heuristicAnnotation.getBegin(),
             heuristicAnnotation.getEnd());
     heuristicAnnotation.setScore(deltaScore);
     heuristicAnnotation.setAnnotation(newAnnotation);
@@ -79,7 +82,7 @@ public class MarkAction extends Abstract
     if (annotationsInWindow.isEmpty()) {
       heuristicAnnotation.addToIndexes();
       newAnnotation.addToIndexes();
-      stream.addAnnotation(newAnnotation, match);
+      stream.addAnnotation(newAnnotation, context.getRuleMatch());
     } else {
       RutaAnnotation tma = stream.getCorrectTMA(annotationsInWindow, heuristicAnnotation);
       if (tma != null) {
@@ -90,7 +93,7 @@ public class MarkAction extends Abstract
       } else {
         heuristicAnnotation.addToIndexes();
         newAnnotation.addToIndexes();
-        stream.addAnnotation(newAnnotation, match);
+        stream.addAnnotation(newAnnotation, context.getRuleMatch());
       }
     }
 

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkFastAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkFastAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkFastAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkFastAction.java Mon Jan  4 10:33:48 2016
@@ -23,7 +23,6 @@ import java.util.Collection;
 import java.util.List;
 
 import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.ruta.RutaBlock;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.bool.IBooleanExpression;
 import org.apache.uima.ruta.expression.bool.SimpleBooleanExpression;
@@ -31,9 +30,10 @@ import org.apache.uima.ruta.expression.l
 import org.apache.uima.ruta.expression.number.INumberExpression;
 import org.apache.uima.ruta.expression.number.SimpleNumberExpression;
 import org.apache.uima.ruta.expression.resource.WordListExpression;
-import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.expression.type.ITypeExpression;
 import org.apache.uima.ruta.resource.RutaWordList;
 import org.apache.uima.ruta.resource.TreeWordList;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
@@ -50,7 +50,7 @@ public class MarkFastAction extends Abst
 
   private IBooleanExpression ignoreWS;
 
-  public MarkFastAction(TypeExpression type, WordListExpression list, IBooleanExpression ignore,
+  public MarkFastAction(ITypeExpression type, WordListExpression list, IBooleanExpression ignore,
           INumberExpression ignoreLength, IBooleanExpression ignoreWS) {
     super(type);
     this.list = list;
@@ -60,7 +60,7 @@ public class MarkFastAction extends Abst
     this.ignoreWS = ignoreWS == null ? new SimpleBooleanExpression(true) : ignoreWS;
   }
 
-  public MarkFastAction(TypeExpression type, StringListExpression list, IBooleanExpression ignore,
+  public MarkFastAction(ITypeExpression type, StringListExpression list, IBooleanExpression ignore,
           INumberExpression ignoreLength, IBooleanExpression ignoreWS) {
     super(type);
     this.stringList = list;
@@ -71,24 +71,26 @@ public class MarkFastAction extends Abst
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
     List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOfElement(element);
     for (AnnotationFS annotationFS : matchedAnnotationsOf) {
       RutaStream windowStream = stream.getWindowStream(annotationFS, annotationFS.getType());
       RutaWordList wl = null;
-      RutaBlock parent = element.getParent();
+      element.getParent();
       if (list != null) {
-        wl = list.getList(parent);
+        wl = list.getList(context);
       } else if (stringList != null) {
-        wl = new TreeWordList(stringList.getList(parent, stream), false);
+        wl = new TreeWordList(stringList.getList(context, stream), false);
       }
       if (wl instanceof TreeWordList) {
         Collection<AnnotationFS> found = wl.find(windowStream,
-                ignore.getBooleanValue(parent, match, element, stream),
-                ignoreLength.getIntegerValue(parent, match, element, stream), null, 0,
-                ignoreWS.getBooleanValue(parent, match, element, stream));
+                ignore.getBooleanValue(context, stream),
+                ignoreLength.getIntegerValue(context, stream), null, 0,
+                ignoreWS.getBooleanValue(context, stream));
         for (AnnotationFS annotation : found) {
-          createAnnotation(annotation, element, windowStream, match);
+          createAnnotation(annotation, context, windowStream);
         }
       }
     }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkFirstAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkFirstAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkFirstAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkFirstAction.java Mon Jan  4 10:33:48 2016
@@ -23,7 +23,8 @@ import java.util.List;
 
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.ruta.RutaStream;
-import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.expression.type.ITypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.type.RutaBasic;
@@ -31,17 +32,19 @@ import org.apache.uima.ruta.visitor.Infe
 
 public class MarkFirstAction extends AbstractMarkAction {
 
-  public MarkFirstAction(TypeExpression type) {
+  public MarkFirstAction(ITypeExpression type) {
     super(type);
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
     List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(null,
             element.getContainer());
     for (AnnotationFS matchedAnnotation : matchedAnnotations) {
       RutaBasic beginAnchor = stream.getBeginAnchor(matchedAnnotation.getBegin());
-      createAnnotation(beginAnchor, element, stream, match);
+      createAnnotation(beginAnchor, context, stream);
     }
   }
 

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkLastAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkLastAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkLastAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkLastAction.java Mon Jan  4 10:33:48 2016
@@ -23,7 +23,8 @@ import java.util.List;
 
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.ruta.RutaStream;
-import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.expression.type.ITypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.type.RutaBasic;
@@ -31,19 +32,21 @@ import org.apache.uima.ruta.visitor.Infe
 
 public class MarkLastAction extends AbstractMarkAction {
 
-  public MarkLastAction(TypeExpression type) {
+  public MarkLastAction(ITypeExpression type) {
     super(type);
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
     List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(null,
             element.getContainer());
     for (AnnotationFS matchedAnnotation : matchedAnnotations) {
       List<RutaBasic> list = stream.getBasicsInWindow(matchedAnnotation);
       if (!list.isEmpty()) {
         RutaBasic last = list.get(list.size() - 1);
-        createAnnotation(last, element, stream, match);
+        createAnnotation(last, context, stream);
       }
 
     }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkOnceAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkOnceAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkOnceAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkOnceAction.java Mon Jan  4 10:33:48 2016
@@ -25,7 +25,8 @@ import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.number.INumberExpression;
-import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.expression.type.ITypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.type.RutaBasic;
@@ -33,17 +34,19 @@ import org.apache.uima.ruta.visitor.Infe
 
 public class MarkOnceAction extends MarkAction {
 
-  public MarkOnceAction(TypeExpression type, INumberExpression scoreValue,
+  public MarkOnceAction(ITypeExpression type, INumberExpression scoreValue,
           List<INumberExpression> list) {
     super(type, scoreValue, list);
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
-    List<Integer> indexList = getIndexList(element, list, stream);
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
+    List<Integer> indexList = getIndexList(context, list, stream);
     List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(indexList,
             element.getContainer());
-    Type targetType = type.getType(element.getParent());
+    Type targetType = type.getType(context, stream);
     for (AnnotationFS matchedAnnotation : matchedAnnotations) {
       boolean partof = false;
       List<RutaBasic> basicsInWindow = stream.getBasicsInWindow(matchedAnnotation);
@@ -54,7 +57,7 @@ public class MarkOnceAction extends Mark
         }
       }
       if (!partof) {
-        createAnnotation(matchedAnnotation, element, stream, match);
+        createAnnotation(matchedAnnotation, context, stream);
       }
     }
   }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkTableAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkTableAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkTableAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkTableAction.java Mon Jan  4 10:33:48 2016
@@ -31,7 +31,6 @@ import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.jcas.cas.TOP;
 import org.apache.uima.jcas.tcas.Annotation;
-import org.apache.uima.ruta.RutaBlock;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.UIMAConstants;
 import org.apache.uima.ruta.expression.bool.IBooleanExpression;
@@ -39,16 +38,17 @@ import org.apache.uima.ruta.expression.b
 import org.apache.uima.ruta.expression.number.INumberExpression;
 import org.apache.uima.ruta.expression.resource.WordTableExpression;
 import org.apache.uima.ruta.expression.string.IStringExpression;
-import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.expression.type.ITypeExpression;
 import org.apache.uima.ruta.resource.RutaTable;
 import org.apache.uima.ruta.resource.RutaWordList;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class MarkTableAction extends AbstractRutaAction {
 
-  private final TypeExpression typeExpr;
+  private final ITypeExpression typeExpr;
 
   private final WordTableExpression tableExpr;
 
@@ -63,10 +63,10 @@ public class MarkTableAction extends Abs
   private final IStringExpression ignoreChar;
 
   private final INumberExpression maxIgnoreChar;
-  
+
   private IBooleanExpression ignoreWS = new SimpleBooleanExpression(true);
 
-  public MarkTableAction(TypeExpression typeExpr, INumberExpression indexExpr,
+  public MarkTableAction(ITypeExpression typeExpr, INumberExpression indexExpr,
           WordTableExpression tableExpr, Map<IStringExpression, INumberExpression> featureMap,
           IBooleanExpression ignoreCase, INumberExpression ignoreLength,
           IStringExpression ignoreChar, INumberExpression maxIgnoreChar) {
@@ -80,33 +80,33 @@ public class MarkTableAction extends Abs
     this.ignoreChar = ignoreChar;
     this.maxIgnoreChar = maxIgnoreChar;
   }
-  
+
   public void setIgnoreWS(IBooleanExpression ignoreWS) {
     this.ignoreWS = ignoreWS;
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
-    RutaBlock block = element.getParent();
-    RutaTable table = tableExpr.getTable(block);
-    int index = indexExpr.getIntegerValue(block, match, element, stream);
-    Type type = typeExpr.getType(block);
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
+    element.getParent();
+    RutaTable table = tableExpr.getTable(context);
+    int index = indexExpr.getIntegerValue(context, stream);
+    Type type = typeExpr.getType(context, stream);
     Map<String, Integer> map = new HashMap<String, Integer>();
     for (IStringExpression each : featureMap.keySet()) {
-      map.put(each.getStringValue(block, match, element, stream), featureMap.get(each)
-              .getIntegerValue(block, match, element, stream));
+      map.put(each.getStringValue(context, stream),
+              featureMap.get(each).getIntegerValue(context, stream));
     }
 
-    boolean ignoreCaseValue = ignoreCase != null ? ignoreCase.getBooleanValue(element.getParent(),
-            match, element, stream) : false;
-    int ignoreLengthValue = ignoreLength != null ? ignoreLength.getIntegerValue(
-            element.getParent(), match, element, stream) : 0;
-    String ignoreCharValue = ignoreChar != null ? ignoreChar.getStringValue(element.getParent(),
-            match, element, stream) : "";
-    int maxIgnoreCharValue = maxIgnoreChar != null ? maxIgnoreChar.getIntegerValue(
-            element.getParent(), match, element, stream) : 0;
-    boolean ignoreWSValue = ignoreWS != null ? ignoreWS.getBooleanValue(element.getParent(),
-            match, element, stream) : false;
+    boolean ignoreCaseValue = ignoreCase != null ? ignoreCase.getBooleanValue(context, stream)
+            : false;
+    int ignoreLengthValue = ignoreLength != null ? ignoreLength.getIntegerValue(context, stream)
+            : 0;
+    String ignoreCharValue = ignoreChar != null ? ignoreChar.getStringValue(context, stream) : "";
+    int maxIgnoreCharValue = maxIgnoreChar != null ? maxIgnoreChar.getIntegerValue(context, stream)
+            : 0;
+    boolean ignoreWSValue = ignoreWS != null ? ignoreWS.getBooleanValue(context, stream) : false;
 
     RutaWordList wordList = table.getWordList(index, element.getParent());
     Collection<AnnotationFS> found = wordList.find(stream, ignoreCaseValue, ignoreLengthValue,
@@ -114,7 +114,7 @@ public class MarkTableAction extends Abs
     for (AnnotationFS annotationFS : found) {
       // HOTFIX: for feature assignment
       String candidate = stream.getVisibleCoveredText(annotationFS);
-      if(!StringUtils.isBlank(ignoreCharValue)) {
+      if (!StringUtils.isBlank(ignoreCharValue)) {
         for (int i = 0; i < maxIgnoreCharValue; i++) {
           candidate = candidate.replaceFirst("[" + ignoreCharValue + "]", "");
         }
@@ -181,7 +181,7 @@ public class MarkTableAction extends Abs
     }
   }
 
-  public TypeExpression getTypeExpr() {
+  public ITypeExpression getTypeExpr() {
     return typeExpr;
   }
 

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MatchedTextAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MatchedTextAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MatchedTextAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MatchedTextAction.java Mon Jan  4 10:33:48 2016
@@ -19,12 +19,12 @@
 
 package org.apache.uima.ruta.action;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.number.INumberExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
@@ -42,8 +42,10 @@ public class MatchedTextAction extends A
   }
 
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
-    List<Integer> indexList = getIndexList(match, element, stream);
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleMatch match = context.getRuleMatch();
+    RuleElement element = context.getElement();
+    List<Integer> indexList = getIndexList(list, context, stream);
     List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(indexList,
             element.getContainer());
     for (AnnotationFS matchedAnnotation : matchedAnnotations) {
@@ -60,22 +62,4 @@ public class MatchedTextAction extends A
     return list;
   }
 
-  protected List<Integer> getIndexList(RuleMatch match, RuleElement element, RutaStream stream) {
-    List<Integer> indexList = new ArrayList<Integer>();
-    if (list == null || list.isEmpty()) {
-      int self = element.getContainer().getRuleElements().indexOf(element) + 1;
-      indexList.add(self);
-      return indexList;
-    }
-    int last = Integer.MAX_VALUE - 1;
-    for (INumberExpression each : list) {
-      // not allowed for feature matches
-      int value = each.getIntegerValue(element.getParent(), null, stream);
-      for (int i = Math.min(value, last + 1); i < value; i++) {
-        indexList.add(i);
-      }
-      indexList.add(value);
-    }
-    return indexList;
-  }
 }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MergeAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MergeAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MergeAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MergeAction.java Mon Jan  4 10:33:48 2016
@@ -26,8 +26,8 @@ import org.apache.commons.collections.Li
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.bool.IBooleanExpression;
 import org.apache.uima.ruta.expression.list.ListExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
-import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class MergeAction extends AbstractRutaAction {
@@ -49,21 +49,23 @@ public class MergeAction extends Abstrac
 
   @SuppressWarnings({ "unchecked", "rawtypes" })
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
-    boolean union = unionExpr.getBooleanValue(element.getParent(), match, element, stream);
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    context.getRuleMatch();
+    RuleElement element = context.getElement();
+    boolean union = unionExpr.getBooleanValue(context, stream);
     List<Object> list = new ArrayList<Object>();
     if (union) {
       for (ListExpression<Object> each : lists) {
-        list.addAll(each.getList(element.getParent(), stream));
+        list.addAll(each.getList(context, stream));
       }
     } else {
       List<Object> lastList = null;
       for (int i = 1; i < lists.size(); i++) {
-        List l2 = lists.get(i).getList(element.getParent(), stream);
+        List l2 = lists.get(i).getList(context, stream);
         if (lastList != null) {
           lastList = ListUtils.intersection(lastList, l2);
         } else {
-          List l1 = lists.get(i - 1).getList(element.getParent(), stream);
+          List l1 = lists.get(i - 1).getList(context, stream);
           lastList = ListUtils.intersection(l1, l2);
         }
       }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveAction.java?rev=1722834&r1=1722833&r2=1722834&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveAction.java Mon Jan  4 10:33:48 2016
@@ -29,9 +29,9 @@ import org.apache.uima.ruta.expression.b
 import org.apache.uima.ruta.expression.list.ListExpression;
 import org.apache.uima.ruta.expression.number.INumberExpression;
 import org.apache.uima.ruta.expression.string.IStringExpression;
-import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.expression.type.ITypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
 import org.apache.uima.ruta.rule.RuleElement;
-import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class RemoveAction extends AbstractRutaAction {
@@ -56,24 +56,25 @@ public class RemoveAction extends Abstra
 
   @SuppressWarnings({ "rawtypes" })
   @Override
-  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
+  public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
+    RuleElement element = context.getElement();
     RutaBlock parent = element.getParent();
     List list = parent.getEnvironment().getVariableValue(var, List.class);
     List<Object> toRemove = new ArrayList<Object>();
     for (Object entry : list) {
-      Object value1 = getValue(entry, parent, stream, match, element);
+      Object value1 = getValue(entry, context, stream);
       for (IRutaExpression arg : elements) {
         if (arg instanceof ListExpression) {
           ListExpression l = (ListExpression) arg;
-          List list2 = l.getList(parent, stream);
+          List list2 = l.getList(context, stream);
           for (Object object : list2) {
-            Object value2 = getValue(object, parent, stream, match, element);
+            Object value2 = getValue(object, context, stream);
             if (value1.equals(value2)) {
               toRemove.add(entry);
             }
           }
         } else {
-          Object value2 = getValue(arg, parent, stream, match, element);
+          Object value2 = getValue(arg, context, stream);
           if (value1.equals(value2)) {
             toRemove.add(entry);
           }
@@ -86,15 +87,15 @@ public class RemoveAction extends Abstra
     parent.getEnvironment().setVariableValue(var, list);
   }
 
-  private Object getValue(Object obj, RutaBlock parent, RutaStream stream, RuleMatch match, RuleElement element) {
+  private Object getValue(Object obj, MatchContext context, RutaStream stream) {
     if (obj instanceof INumberExpression) {
-      return ((INumberExpression) obj).getDoubleValue(parent, match, element, stream);
+      return ((INumberExpression) obj).getDoubleValue(context, stream);
     } else if (obj instanceof IBooleanExpression) {
-      return ((IBooleanExpression) obj).getBooleanValue(parent, match, element, stream);
-    } else if (obj instanceof TypeExpression) {
-      return ((TypeExpression) obj).getType(parent);
+      return ((IBooleanExpression) obj).getBooleanValue(context, stream);
+    } else if (obj instanceof ITypeExpression) {
+      return ((ITypeExpression) obj).getType(context, stream);
     } else if (obj instanceof IStringExpression) {
-      return ((IStringExpression) obj).getStringValue(parent, match, element, stream);
+      return ((IStringExpression) obj).getStringValue(context, stream);
     }
     return null;
   }