You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by jo...@apache.org on 2011/08/12 12:44:18 UTC

svn commit: r1157040 [5/23] - in /uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine: ./ .settings/ META-INF/ desc/ lib/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/uima/ src/main/java/org/a...

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ReplaceAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ReplaceAction.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ReplaceAction.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ReplaceAction.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.action;
+
+import java.util.List;
+
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.string.StringExpression;
+import org.apache.uima.textmarker.rule.RuleMatch;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.type.TextMarkerBasic;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+
+public class ReplaceAction extends AbstractTextMarkerAction {
+
+  public StringExpression getReplacement() {
+    return replacement;
+  }
+
+  private final StringExpression replacement;
+
+  public ReplaceAction(StringExpression replacement) {
+    super();
+    this.replacement = replacement;
+  }
+
+  @Override
+  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+          InferenceCrowd crowd) {
+    AnnotationFS matchedAnnotation = match.getMatchedAnnotation(stream, null);
+    List<TextMarkerBasic> annotationsInWindow = stream.getBasicsInWindow(matchedAnnotation);
+    boolean replaced = false;
+    for (TextMarkerBasic textMarkerBasic : annotationsInWindow) {
+      textMarkerBasic.setReplacement(replaced ? "" : replacement
+              .getStringValue(element.getParent()));
+      replaced = true;
+    }
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ReplaceAction.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ReplaceAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RetainMarkupAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RetainMarkupAction.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RetainMarkupAction.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RetainMarkupAction.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.action;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.string.StringExpression;
+import org.apache.uima.textmarker.rule.RuleMatch;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+
+public class RetainMarkupAction extends AbstractTextMarkerAction {
+
+  private List<StringExpression> markup;
+
+  public RetainMarkupAction(List<StringExpression> markup) {
+    super();
+    this.markup = markup;
+  }
+
+  @Override
+  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+          InferenceCrowd crowd) {
+    List<String> list = new ArrayList<String>();
+    for (StringExpression each : markup) {
+      list.add(each.getStringValue(element.getParent()));
+    }
+    stream.retainTags(list);
+  }
+
+  public List<StringExpression> getMarkup() {
+    return markup;
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RetainMarkupAction.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RetainMarkupAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RetainTypeAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RetainTypeAction.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RetainTypeAction.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RetainTypeAction.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.action;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.RuleMatch;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class RetainTypeAction extends AbstractTextMarkerAction {
+
+  public List<TypeExpression> getList() {
+    return list;
+  }
+
+  private List<TypeExpression> list;
+
+  public RetainTypeAction(List<TypeExpression> list) {
+    super();
+    this.list = list;
+  }
+
+  @Override
+  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+          InferenceCrowd crowd) {
+    List<Type> types = new ArrayList<Type>();
+    for (TypeExpression each : list) {
+      types.add(each.getType(element.getParent()));
+    }
+    stream.retainTypes(types);
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RetainTypeAction.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RetainTypeAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/SetFeatureAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/SetFeatureAction.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/SetFeatureAction.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/SetFeatureAction.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.action;
+
+import java.util.List;
+
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.bool.BooleanExpression;
+import org.apache.uima.textmarker.expression.number.NumberExpression;
+import org.apache.uima.textmarker.expression.string.StringExpression;
+import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.RuleMatch;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.utils.UIMAUtils;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class SetFeatureAction extends AbstractTextMarkerAction {
+
+  private final StringExpression featureStringExpression;
+
+  private StringExpression stringExpr;
+
+  private NumberExpression numberExpr;
+
+  private BooleanExpression booleanExpr;
+
+  private TypeExpression typeExpr;
+
+  protected SetFeatureAction(StringExpression feature) {
+    super();
+    this.featureStringExpression = feature;
+  }
+
+  public SetFeatureAction(StringExpression feature, StringExpression stringExpr) {
+    this(feature);
+    this.stringExpr = stringExpr;
+  }
+
+  public SetFeatureAction(StringExpression feature, NumberExpression numberExpr) {
+    this(feature);
+    this.numberExpr = numberExpr;
+  }
+
+  public SetFeatureAction(StringExpression feature, BooleanExpression booleanExpr) {
+    this(feature);
+    this.booleanExpr = booleanExpr;
+  }
+
+  public SetFeatureAction(StringExpression feature, TypeExpression typeExpr) {
+    this(feature);
+    this.typeExpr = typeExpr;
+  }
+
+  public StringExpression getFeatureStringExpression() {
+    return featureStringExpression;
+  }
+
+  public StringExpression getStringExpr() {
+    return stringExpr;
+  }
+
+  public NumberExpression getNumberExpr() {
+    return numberExpr;
+  }
+
+  public BooleanExpression getBooleanExpr() {
+    return booleanExpr;
+  }
+
+  public TypeExpression getTypeExpr() {
+    return typeExpr;
+  }
+
+  @Override
+  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+          InferenceCrowd crowd) {
+    Type type = element.getMatcher().getType(element.getParent(), stream);
+    if (type == null)
+      return;
+    String featureString = featureStringExpression.getStringValue(element.getParent());
+    Feature featureByBaseName = type.getFeatureByBaseName(featureString);
+    Annotation expandAnchor = (Annotation) stream.expandAnchor(match.getFirstBasic(), type);
+    if (expandAnchor.getType().getFeatureByBaseName(featureString) == null) {
+      System.out.println("Can't access feature " + featureString
+              + ", because it's not defined in the matched type: " + expandAnchor.getType());
+      return;
+    }
+    expandAnchor.removeFromIndexes();
+    if (stringExpr != null) {
+      String string = stringExpr.getStringValue(element.getParent());
+      expandAnchor.setStringValue(featureByBaseName, string);
+    } else if (numberExpr != null) {
+      String range = featureByBaseName.getRange().getName();
+      if (range.equals("uima.cas.Integer")) {
+        int v = numberExpr.getIntegerValue(element.getParent());
+        expandAnchor.setIntValue(featureByBaseName, v);
+      } else if (range.equals("uima.cas.Double")) {
+        double v = numberExpr.getDoubleValue(element.getParent());
+        expandAnchor.setDoubleValue(featureByBaseName, v);
+      }
+    } else if (booleanExpr != null) {
+      boolean v = booleanExpr.getBooleanValue(element.getParent());
+      expandAnchor.setBooleanValue(featureByBaseName, v);
+    } else if (typeExpr != null) {
+      Type t = typeExpr.getType(element.getParent());
+      List<AnnotationFS> inWindow = stream.getAnnotationsInWindow(expandAnchor, t);
+      if (featureByBaseName.getRange().isArray()) {
+        expandAnchor.setFeatureValue(featureByBaseName,
+                UIMAUtils.toFSArray(stream.getJCas(), inWindow));
+      } else {
+        AnnotationFS annotation = inWindow.get(0);
+        expandAnchor.setFeatureValue(featureByBaseName, annotation);
+      }
+    }
+    expandAnchor.addToIndexes();
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/SetFeatureAction.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/SetFeatureAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TransferAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TransferAction.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TransferAction.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TransferAction.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.action;
+
+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.TextMarkerStream;
+import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.RuleElementMatch;
+import org.apache.uima.textmarker.rule.RuleMatch;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.type.TextMarkerBasic;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class TransferAction extends TypeSensitiveAction {
+
+  public TransferAction(TypeExpression type) {
+    super(type);
+  }
+
+  @Override
+  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+          InferenceCrowd crowd) {
+    List<RuleElementMatch> list = match.getMatchInfos().get(element);
+    CAS cas = stream.getCas();
+    Type t = type.getType(element.getParent());
+    for (RuleElementMatch each : list) {
+      List<AnnotationFS> matched = each.getTextsMatched();
+      for (AnnotationFS annotationFS : matched) {
+        FeatureStructure createFS = cas.createFS(t);
+        copyFeatures(annotationFS, createFS, cas);
+        if (createFS instanceof AnnotationFS) {
+          TextMarkerBasic basic = stream.getFirstBasicInWindow(annotationFS);
+          stream.addAnnotation(basic, (AnnotationFS) createFS);
+        }
+        cas.addFsToIndexes(createFS);
+      }
+    }
+
+  }
+
+  private void copyFeatures(AnnotationFS oldFS, FeatureStructure newFS, CAS cas) {
+    List<?> features = oldFS.getType().getFeatures();
+    Type newType = newFS.getType();
+    for (Object object : features) {
+      Feature feature = (Feature) object;
+      String shortName = feature.getShortName();
+      Feature newFeature = newType.getFeatureByBaseName(shortName);
+      if (newFeature != null) {
+        if (feature.getRange().isPrimitive()) {
+          String value = oldFS.getFeatureValueAsString(newFeature);
+          newFS.setFeatureValueFromString(newFeature, value);
+        } else {
+          FeatureStructure value = oldFS.getFeatureValue(feature);
+          newFS.setFeatureValue(newFeature, value);
+        }
+      }
+    }
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TransferAction.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TransferAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TrieAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TrieAction.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TrieAction.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TrieAction.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.action;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.bool.BooleanExpression;
+import org.apache.uima.textmarker.expression.number.NumberExpression;
+import org.apache.uima.textmarker.expression.resource.WordListExpression;
+import org.apache.uima.textmarker.expression.string.StringExpression;
+import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.resource.TextMarkerWordList;
+import org.apache.uima.textmarker.rule.RuleMatch;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.type.TextMarkerBasic;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class TrieAction extends AbstractTextMarkerAction {
+
+  private final WordListExpression list;
+
+  private final Map<StringExpression, TypeExpression> map;
+
+  private final BooleanExpression ignoreCase;
+
+  private final NumberExpression ignoreLength;
+
+  private final BooleanExpression edit;
+
+  private final NumberExpression distance;
+
+  private final StringExpression ignoreChar;
+
+  public TrieAction(WordListExpression list, Map<StringExpression, TypeExpression> map,
+          BooleanExpression ignoreCase, NumberExpression ignoreLength, BooleanExpression edit,
+          NumberExpression distance, StringExpression ignoreChar) {
+    this.list = list;
+    this.map = map;
+    this.ignoreCase = ignoreCase;
+    this.ignoreLength = ignoreLength;
+    this.edit = edit;
+    this.distance = distance;
+    this.ignoreChar = ignoreChar;
+  }
+
+  @Override
+  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+          InferenceCrowd crowd) {
+
+    Map<String, Type> typeMap = new HashMap<String, Type>();
+    for (StringExpression eachKey : map.keySet()) {
+      String stringValue = eachKey.getStringValue(element.getParent());
+      TypeExpression typeExpression = map.get(eachKey);
+      if (typeExpression != null) {
+        Type typeValue = typeExpression.getType(element.getParent());
+        typeMap.put(stringValue, typeValue);
+      }
+    }
+    boolean ignoreCaseValue = ignoreCase.getBooleanValue(element.getParent());
+    int ignoreLengthValue = ignoreLength.getIntegerValue(element.getParent());
+    boolean editValue = edit.getBooleanValue(element.getParent());
+    double distanceValue = distance.getDoubleValue(element.getParent());
+    String ignoreCharValue = ignoreChar.getStringValue(element.getParent());
+
+    TextMarkerWordList wl = list.getList(element.getParent());
+    Collection<AnnotationFS> found = wl.find(stream, typeMap, ignoreCaseValue, ignoreLengthValue,
+            editValue, distanceValue, ignoreCharValue);
+
+    if (found != null) {
+      for (AnnotationFS annotation : found) {
+        TextMarkerBasic anchor = stream.getFirstBasicInWindow(annotation);
+        stream.addAnnotation(anchor, annotation);
+        stream.getCas().addFsToIndexes(annotation);
+      }
+    }
+
+  }
+
+  public WordListExpression getList() {
+    return list;
+  }
+
+  public Map<StringExpression, TypeExpression> getMap() {
+    return map;
+  }
+
+  public BooleanExpression getIgnoreCase() {
+    return ignoreCase;
+  }
+
+  public NumberExpression getIgnoreLength() {
+    return ignoreLength;
+  }
+
+  public BooleanExpression getEdit() {
+    return edit;
+  }
+
+  public NumberExpression getDistance() {
+    return distance;
+  }
+
+  public StringExpression getIgnoreChar() {
+    return ignoreChar;
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TrieAction.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TrieAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TypeSensitiveAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TypeSensitiveAction.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TypeSensitiveAction.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TypeSensitiveAction.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.action;
+
+import org.apache.uima.textmarker.expression.type.TypeExpression;
+
+public abstract class TypeSensitiveAction extends AbstractTextMarkerAction {
+
+  protected TypeExpression type;
+
+  public TypeExpression getType() {
+    return type;
+  }
+
+  public TypeSensitiveAction(TypeExpression type) {
+    super();
+    this.type = type;
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TypeSensitiveAction.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TypeSensitiveAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/UnmarkAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/UnmarkAction.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/UnmarkAction.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/UnmarkAction.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.action;
+
+import java.util.List;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.RuleElementMatch;
+import org.apache.uima.textmarker.rule.RuleMatch;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.type.TextMarkerBasic;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class UnmarkAction extends TypeSensitiveAction {
+
+  public UnmarkAction(TypeExpression type) {
+    super(type);
+  }
+
+  @Override
+  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+          InferenceCrowd crowd) {
+    List<RuleElementMatch> matchInfo = match.getMatchInfo(element);
+    if (matchInfo == null || matchInfo.isEmpty()) {
+      return;
+    }
+    RuleElementMatch ruleElementMatch = matchInfo.get(0);
+    List<AnnotationFS> textsMatched = ruleElementMatch.getTextsMatched();
+    AnnotationFS first = textsMatched.get(0);
+    TextMarkerBasic firstBasicInWindow = stream.getFirstBasicInWindow(first);
+    Type t = type.getType(element.getParent());
+    stream.removeAnnotation(firstBasicInWindow, t);
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/UnmarkAction.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/UnmarkAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/UnmarkAllAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/UnmarkAllAction.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/UnmarkAllAction.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/UnmarkAllAction.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.action;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.list.TypeListExpression;
+import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.RuleElementMatch;
+import org.apache.uima.textmarker.rule.RuleMatch;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.type.TextMarkerBasic;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class UnmarkAllAction extends TypeSensitiveAction {
+
+  private TypeListExpression list;
+
+  public UnmarkAllAction(TypeExpression type, TypeListExpression list) {
+    super(type);
+    this.list = list;
+  }
+
+  @Override
+  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+          InferenceCrowd crowd) {
+    List<RuleElementMatch> matchInfo = match.getMatchInfo(element);
+    if (matchInfo == null || matchInfo.isEmpty()) {
+      return;
+    }
+    RuleElementMatch ruleElementMatch = matchInfo.get(0);
+    List<AnnotationFS> textsMatched = ruleElementMatch.getTextsMatched();
+    AnnotationFS first = textsMatched.get(0);
+    TextMarkerBasic firstBasicInWindow = stream.getFirstBasicInWindow(first);
+    Type t = type.getType(element.getParent());
+    TypeSystem typeSystem = stream.getCas().getTypeSystem();
+    List<Type> properlySubsumedTypes = typeSystem.getProperlySubsumedTypes(t);
+    List<Type> retainList = new ArrayList<Type>();
+
+    if (list != null) {
+      retainList = list.getList(element.getParent());
+    }
+
+    for (Type type : properlySubsumedTypes) {
+      boolean keep = false;
+      for (Type retainType : retainList) {
+        if (typeSystem.subsumes(retainType, type)) {
+          keep = true;
+          break;
+        }
+      }
+      if (!keep) {
+        stream.removeAnnotation(firstBasicInWindow, type);
+      }
+    }
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/UnmarkAllAction.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/UnmarkAllAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/VariableAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/VariableAction.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/VariableAction.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/VariableAction.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.action;
+
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.rule.RuleMatch;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class VariableAction extends AbstractTextMarkerAction {
+
+  private final String var;
+
+  public VariableAction(String var) {
+    super();
+    this.var = var;
+  }
+
+  @Override
+  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+          InferenceCrowd crowd) {
+
+  }
+
+  public String getVar() {
+    return var;
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/VariableAction.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/VariableAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AbstractTextMarkerCondition.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AbstractTextMarkerCondition.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AbstractTextMarkerCondition.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AbstractTextMarkerCondition.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.condition;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.textmarker.TextMarkerElement;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.rule.EvaluatedCondition;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.type.TextMarkerBasic;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public abstract class AbstractTextMarkerCondition extends TextMarkerElement {
+
+  public abstract EvaluatedCondition eval(TextMarkerBasic basic, Type matchedType,
+          TextMarkerRuleElement element, TextMarkerStream stream, InferenceCrowd crowd);
+
+  @Override
+  public String toString() {
+    return getClass().getSimpleName();
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AbstractTextMarkerCondition.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AbstractTextMarkerCondition.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AfterCondition.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AfterCondition.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AfterCondition.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AfterCondition.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.condition;
+
+import java.util.List;
+
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.list.TypeListExpression;
+import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.EvaluatedCondition;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.type.TextMarkerBasic;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class AfterCondition extends TypeSentiveCondition {
+
+  public AfterCondition(TypeExpression type) {
+    super(type);
+  }
+
+  public AfterCondition(TypeListExpression list) {
+    super(list);
+  }
+
+  @Override
+  public EvaluatedCondition eval(TextMarkerBasic basic, Type matchedType,
+          TextMarkerRuleElement element, TextMarkerStream stream, InferenceCrowd crowd) {
+    if (!isWorkingOnList()) {
+      Type t = type.getType(element.getParent());
+      boolean result = check(basic, stream, t);
+      return new EvaluatedCondition(this, result);
+    } else {
+      boolean result = false;
+      List<Type> types = getList().getList(element.getParent());
+      for (Type t : types) {
+        result |= check(basic, stream, t);
+        if (result == true) {
+          break;
+        }
+      }
+      return new EvaluatedCondition(this, result);
+    }
+  }
+
+  private boolean check(TextMarkerBasic basic, TextMarkerStream stream, Type t) {
+    boolean result = false;
+    FSIterator<AnnotationFS> it = stream.getCas().getAnnotationIndex(t).iterator(basic);
+    if (!it.isValid()) {
+      it.moveToLast();
+    }
+    while (it.isValid()) {
+      AnnotationFS a = (AnnotationFS) it.get();
+      if (a.getBegin() <= basic.getBegin()) {
+        result = true;
+        break;
+      }
+      it.moveToPrevious();
+    }
+    return result;
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AfterCondition.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AfterCondition.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AndCondition.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AndCondition.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AndCondition.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AndCondition.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.condition;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.rule.EvaluatedCondition;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.type.TextMarkerBasic;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class AndCondition extends ComposedTextMarkerCondition {
+
+  public AndCondition(List<AbstractTextMarkerCondition> conditions) {
+    super(conditions);
+  }
+
+  @Override
+  public EvaluatedCondition eval(TextMarkerBasic currentSymbol, Type matchedType,
+          TextMarkerRuleElement element, TextMarkerStream symbolStream, InferenceCrowd crowd) {
+    boolean result = true;
+    List<EvaluatedCondition> evals = new ArrayList<EvaluatedCondition>();
+    for (AbstractTextMarkerCondition each : conditions) {
+      crowd.beginVisit(each, null);
+      EvaluatedCondition eval = each.eval(currentSymbol, matchedType, element, symbolStream, crowd);
+      crowd.endVisit(each, null);
+      result &= eval.isValue();
+      evals.add(eval);
+    }
+    return new EvaluatedCondition(this, result, evals);
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AndCondition.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AndCondition.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/BeforeCondition.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/BeforeCondition.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/BeforeCondition.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/BeforeCondition.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.condition;
+
+import java.util.List;
+
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.list.TypeListExpression;
+import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.EvaluatedCondition;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.type.TextMarkerBasic;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class BeforeCondition extends TypeSentiveCondition {
+
+  public BeforeCondition(TypeExpression type) {
+    super(type);
+  }
+
+  public BeforeCondition(TypeListExpression list) {
+    super(list);
+  }
+
+  @Override
+  public EvaluatedCondition eval(TextMarkerBasic basic, Type matchedType,
+          TextMarkerRuleElement element, TextMarkerStream stream, InferenceCrowd crowd) {
+    if (!isWorkingOnList()) {
+      Type t = type.getType(element.getParent());
+      boolean result = check(basic, stream, t);
+      return new EvaluatedCondition(this, result);
+    } else {
+      boolean result = false;
+      List<Type> types = getList().getList(element.getParent());
+      for (Type t : types) {
+        result |= check(basic, stream, t);
+        if (result == true) {
+          break;
+        }
+      }
+      return new EvaluatedCondition(this, result);
+    }
+  }
+
+  private boolean check(TextMarkerBasic basic, TextMarkerStream stream, Type t) {
+    boolean result = false;
+    FSIterator<AnnotationFS> it = stream.getCas().getAnnotationIndex(t).iterator(basic);
+    while (it.isValid()) {
+      AnnotationFS a = (AnnotationFS) it.get();
+      if (a.getEnd() >= basic.getBegin()) {
+        result = true;
+        break;
+      }
+      it.moveToNext();
+    }
+    return result;
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/BeforeCondition.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/BeforeCondition.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ComposedTextMarkerCondition.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ComposedTextMarkerCondition.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ComposedTextMarkerCondition.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ComposedTextMarkerCondition.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.condition;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class ComposedTextMarkerCondition extends AbstractTextMarkerCondition {
+
+  protected List<AbstractTextMarkerCondition> conditions;
+
+  public ComposedTextMarkerCondition(List<AbstractTextMarkerCondition> conditions) {
+    super();
+    this.conditions = conditions;
+  }
+
+  public ComposedTextMarkerCondition(AbstractTextMarkerCondition condition) {
+    super();
+    this.conditions = new ArrayList<AbstractTextMarkerCondition>();
+    this.conditions.add(condition);
+  }
+
+  public List<AbstractTextMarkerCondition> getConditions() {
+    return conditions;
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ComposedTextMarkerCondition.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ComposedTextMarkerCondition.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,260 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.condition;
+
+import java.util.List;
+
+import org.antlr.runtime.Token;
+import org.apache.uima.textmarker.TextMarkerBlock;
+import org.apache.uima.textmarker.expression.TextMarkerExpression;
+import org.apache.uima.textmarker.expression.bool.BooleanExpression;
+import org.apache.uima.textmarker.expression.list.ListExpression;
+import org.apache.uima.textmarker.expression.list.StringListExpression;
+import org.apache.uima.textmarker.expression.list.TypeListExpression;
+import org.apache.uima.textmarker.expression.number.NumberExpression;
+import org.apache.uima.textmarker.expression.resource.WordListExpression;
+import org.apache.uima.textmarker.expression.string.StringExpression;
+import org.apache.uima.textmarker.expression.type.TypeExpression;
+
+public class ConditionFactory {
+
+  private ConditionFactory() {
+  }
+
+  public static AbstractTextMarkerCondition createConditionAnd(
+          List<AbstractTextMarkerCondition> conds, TextMarkerBlock parent) {
+    return new AndCondition(conds);
+  }
+
+  public static AbstractTextMarkerCondition createConditionOr(
+          List<AbstractTextMarkerCondition> conds, TextMarkerBlock parent) {
+    return new OrCondition(conds);
+  }
+
+  public static AbstractTextMarkerCondition createConditionNot(AbstractTextMarkerCondition cond,
+          TextMarkerBlock parent) {
+    return new NotCondition(cond);
+  }
+
+  public static AbstractTextMarkerCondition createConditionContains(TypeExpression typeExpr,
+          NumberExpression min, NumberExpression max, BooleanExpression percent,
+          TextMarkerBlock parent) {
+    return new ContainsCondition(typeExpr, min, max, percent);
+  }
+
+  public static AbstractTextMarkerCondition createConditionContextCount(TypeExpression typeExpr,
+          NumberExpression min, NumberExpression max, Token var, TextMarkerBlock parent) {
+    String varString = null;
+    if (var != null) {
+      varString = var.getText();
+    }
+    return new ContextCountCondition(typeExpr, min, max, varString);
+  }
+
+  public static AbstractTextMarkerCondition createConditionCurrentCount(TypeExpression typeExpr,
+          NumberExpression min, NumberExpression max, Token var, TextMarkerBlock parent) {
+    String varString = null;
+    if (var != null) {
+      varString = var.getText();
+    }
+    return new CurrentCountCondition(typeExpr, min, max, varString);
+  }
+
+  public static AbstractTextMarkerCondition createConditionCount(TypeExpression typeExpr,
+          NumberExpression min, NumberExpression max, Token var, TextMarkerBlock parent) {
+    String varString = null;
+    if (var != null) {
+      varString = var.getText();
+    }
+    return new CountCondition(typeExpr, min, max, varString);
+  }
+
+  public static AbstractTextMarkerCondition createConditionTotalCount(TypeExpression typeExpr,
+          NumberExpression min, NumberExpression max, Token var, TextMarkerBlock parent) {
+    String varString = null;
+    if (var != null) {
+      varString = var.getText();
+    }
+    return new TotalCountCondition(typeExpr, min, max, varString);
+  }
+
+  public static AbstractTextMarkerCondition createConditionInList(WordListExpression listExpr,
+          NumberExpression dist, BooleanExpression rel, TextMarkerBlock parent) {
+    return new InListCondition(listExpr, dist, rel);
+  }
+
+  public static AbstractTextMarkerCondition createConditionIsInTag(StringExpression id,
+          List<StringExpression> list1, List<StringExpression> list2, TextMarkerBlock parent) {
+    return new IsInTagCondition(id, list1, list2);
+  }
+
+  public static AbstractTextMarkerCondition createConditionMOfN(
+          List<AbstractTextMarkerCondition> conds, NumberExpression min, NumberExpression max,
+          TextMarkerBlock parent) {
+    return new MOfNCondition(conds, min, max);
+  }
+
+  public static AbstractTextMarkerCondition createConditionNear(TypeExpression typeExpr,
+          NumberExpression min, NumberExpression max, BooleanExpression direction,
+          BooleanExpression filtered, TextMarkerBlock parent) {
+    return new NearCondition(typeExpr, min, max, direction, filtered);
+  }
+
+  public static AbstractTextMarkerCondition createConditionPartOf(TypeExpression type,
+          TypeListExpression list, TextMarkerBlock parent) {
+    if (type != null) {
+      return new PartOfCondition(type);
+    } else {
+      return new PartOfCondition(list);
+    }
+  }
+
+  public static AbstractTextMarkerCondition createConditionPosition(TypeExpression typeExpr,
+          NumberExpression pos, TextMarkerBlock parent) {
+    return new PositionCondition(typeExpr, pos);
+  }
+
+  public static AbstractTextMarkerCondition createConditionRegExp(StringExpression patternExpr,
+          BooleanExpression ignoreCase, TextMarkerBlock parent) {
+    return new RegExpCondition(patternExpr, ignoreCase);
+  }
+
+  public static AbstractTextMarkerCondition createConditionScore(NumberExpression min,
+          NumberExpression max, Token var, TextMarkerBlock parent) {
+    String varString = null;
+    if (var != null) {
+      varString = var.getText();
+    }
+    return new ScoreCondition(min, max, varString);
+  }
+
+  public static AbstractTextMarkerCondition createConditionVote(TypeExpression type1Expr,
+          TypeExpression type2Expr, TextMarkerBlock parent) {
+    return new VoteCondition(type1Expr, type2Expr);
+  }
+
+  public static AbstractTextMarkerCondition createConditionLast(TypeExpression typeExpr,
+          TextMarkerBlock parent) {
+    return new LastCondition(typeExpr);
+  }
+
+  public static AbstractTextMarkerCondition createConditionIf(BooleanExpression e,
+          TextMarkerBlock parent) {
+    return new IfCondition(e);
+  }
+
+  public static AbstractTextMarkerCondition createConditionFeature(StringExpression se, Object v,
+          TextMarkerBlock parent) {
+    if (v instanceof NumberExpression) {
+      return new FeatureCondition(se, (NumberExpression) v);
+    } else if (v instanceof StringExpression) {
+      return new FeatureCondition(se, (StringExpression) v);
+    } else if (v instanceof BooleanExpression) {
+      return new FeatureCondition(se, (BooleanExpression) v);
+    }
+    return null;
+  }
+
+  public static AbstractTextMarkerCondition createConditionParse(Token id, TextMarkerBlock env) {
+    String var = id == null ? "" : id.getText();
+    return new ParseCondition(var);
+  }
+
+  public static AbstractTextMarkerCondition createConditionVariable(Token id) {
+    return new VariableCondition(id.getText());
+  }
+
+  public static AbstractTextMarkerCondition createConditionIs(TypeExpression type,
+          TypeListExpression list, TextMarkerBlock env) {
+    if (type != null) {
+      return new IsCondition(type);
+    } else {
+      return new IsCondition(list);
+    }
+  }
+
+  public static AbstractTextMarkerCondition createConditionAfter(TypeExpression type,
+          TypeListExpression list, TextMarkerBlock env) {
+    if (type != null) {
+      return new AfterCondition(type);
+    } else {
+      return new AfterCondition(list);
+    }
+  }
+
+  public static AbstractTextMarkerCondition createConditionBefore(TypeExpression type,
+          TypeListExpression list, TextMarkerBlock env) {
+    if (type != null) {
+      return new BeforeCondition(type);
+    } else {
+      return new BeforeCondition(list);
+    }
+  }
+
+  public static AbstractTextMarkerCondition createConditionEndsWith(TypeExpression type,
+          TypeListExpression list, TextMarkerBlock env) {
+    if (type != null) {
+      return new EndsWithCondition(type);
+    } else {
+      return new EndsWithCondition(list);
+    }
+  }
+
+  public static AbstractTextMarkerCondition createConditionStartsWith(TypeExpression type,
+          TypeListExpression list, TextMarkerBlock env) {
+    if (type != null) {
+      return new StartsWithCondition(type);
+    } else {
+      return new StartsWithCondition(list);
+    }
+  }
+
+  public static AbstractTextMarkerCondition createConditionPartOfNeq(TypeExpression type,
+          TypeListExpression list, TextMarkerBlock env) {
+    if (type != null) {
+      return new PartOfNeqCondition(type);
+    } else {
+      return new PartOfNeqCondition(list);
+    }
+  }
+
+  public static AbstractTextMarkerCondition createConditionSize(ListExpression<?> list,
+          NumberExpression min, NumberExpression max, Token var, TextMarkerBlock env) {
+    return new SizeCondition(list, min, max, var == null ? null : var.getText());
+  }
+
+  public static AbstractTextMarkerCondition createConditionInList(StringListExpression list,
+          NumberExpression dist, BooleanExpression rel, TextMarkerBlock env) {
+    return new InListCondition(list, dist, rel);
+  }
+
+  public static AbstractTextMarkerCondition createConditionCount(ListExpression<Object> type,
+          TextMarkerExpression a, NumberExpression min, NumberExpression max, Token var,
+          TextMarkerBlock env) {
+    return new CountCondition(type, a, min, max, var == null ? null : var.getText());
+  }
+
+  public static AbstractTextMarkerCondition createConditionContains(ListExpression list,
+          TextMarkerExpression a, NumberExpression min, NumberExpression max,
+          BooleanExpression percent, TextMarkerBlock env) {
+    return new ContainsCondition(list, a, min, max, percent);
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ContainsCondition.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ContainsCondition.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ContainsCondition.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ContainsCondition.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.condition;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.TextMarkerExpression;
+import org.apache.uima.textmarker.expression.bool.BooleanExpression;
+import org.apache.uima.textmarker.expression.bool.SimpleBooleanExpression;
+import org.apache.uima.textmarker.expression.list.BooleanListExpression;
+import org.apache.uima.textmarker.expression.list.ListExpression;
+import org.apache.uima.textmarker.expression.list.NumberListExpression;
+import org.apache.uima.textmarker.expression.list.StringListExpression;
+import org.apache.uima.textmarker.expression.list.TypeListExpression;
+import org.apache.uima.textmarker.expression.number.NumberExpression;
+import org.apache.uima.textmarker.expression.number.SimpleNumberExpression;
+import org.apache.uima.textmarker.expression.string.StringExpression;
+import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.EvaluatedCondition;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.type.TextMarkerBasic;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class ContainsCondition extends TypeSentiveCondition {
+
+  private final NumberExpression min;
+
+  private final NumberExpression max;
+
+  private final BooleanExpression percent;
+
+  private TextMarkerExpression arg;
+
+  private ListExpression argList;
+
+  public ContainsCondition(TypeExpression type, NumberExpression min, NumberExpression max,
+          BooleanExpression percent) {
+    super(type);
+    this.min = min == null ? new SimpleNumberExpression(Integer.valueOf(1)) : min;
+    this.max = max == null ? new SimpleNumberExpression(Integer.MAX_VALUE) : max;
+    this.percent = percent == null ? new SimpleBooleanExpression(false) : percent;
+  }
+
+  public ContainsCondition(ListExpression list, TextMarkerExpression a, NumberExpression min,
+          NumberExpression max, BooleanExpression percent) {
+    super((TypeExpression) null);
+    this.min = min == null ? new SimpleNumberExpression(Integer.valueOf(1)) : min;
+    this.max = max == null ? new SimpleNumberExpression(Integer.MAX_VALUE) : max;
+    this.percent = percent == null ? new SimpleBooleanExpression(false) : percent;
+    this.argList = list;
+    this.arg = a;
+  }
+
+  @Override
+  public EvaluatedCondition eval(TextMarkerBasic basic, Type matchedType,
+          TextMarkerRuleElement element, TextMarkerStream stream, InferenceCrowd crowd) {
+    int basicCount = 0;
+    int anchorCount = 0;
+    int totalCount = 0;
+
+    if (type != null) {
+      if (matchedType == null) {
+        matchedType = (Type) stream.getJCas().getType(Annotation.type);
+      }
+      AnnotationFS annotation = stream.expandAnchor(basic, matchedType);
+      if (annotation != null) {
+        List<TextMarkerBasic> annotations = stream.getBasicsInWindow(annotation);
+        for (TextMarkerBasic each : annotations) {
+          totalCount++;
+          Type t = type.getType(element.getParent());
+          if (each.isAnchorOf(t.getName())
+                  || stream.getCas().getTypeSystem().subsumes(t, each.getType())) {
+            anchorCount++;
+            basicCount++;
+          } else if (each.isPartOf(t.getName())) {
+            basicCount++;
+          }
+        }
+      }
+    } else {
+      totalCount = argList.getList(element.getParent()).size();
+      if (arg instanceof BooleanExpression && argList instanceof BooleanListExpression) {
+        BooleanExpression e = (BooleanExpression) arg;
+        BooleanListExpression le = (BooleanListExpression) argList;
+        boolean v = e.getBooleanValue(element.getParent());
+        List<Boolean> l = new ArrayList<Boolean>(le.getList(element.getParent()));
+        while (l.remove(v)) {
+          basicCount++;
+        }
+      } else if (arg instanceof NumberExpression && argList instanceof NumberListExpression) {
+        NumberExpression e = (NumberExpression) arg;
+        NumberListExpression le = (NumberListExpression) argList;
+        Number v = e.getDoubleValue(element.getParent());
+        List<Number> l = new ArrayList<Number>(le.getList(element.getParent()));
+        while (l.remove(v)) {
+          basicCount++;
+        }
+      } else if (arg instanceof StringExpression && argList instanceof StringListExpression) {
+        StringExpression e = (StringExpression) arg;
+        StringListExpression le = (StringListExpression) argList;
+        String v = e.getStringValue(element.getParent());
+        List<String> l = new ArrayList<String>(le.getList(element.getParent()));
+        while (l.remove(v)) {
+          basicCount++;
+        }
+      } else if (arg instanceof TypeExpression && argList instanceof TypeListExpression) {
+        TypeExpression e = (TypeExpression) arg;
+        TypeListExpression le = (TypeListExpression) argList;
+        Type v = e.getType(element.getParent());
+        List<Type> l = new ArrayList<Type>(le.getList(element.getParent()));
+        while (l.remove(v)) {
+          basicCount++;
+        }
+      }
+      anchorCount = basicCount;
+    }
+    if (percent.getBooleanValue(element.getParent())) {
+      double percentValue = 0;
+      if (totalCount != 0) {
+        percentValue = (((double) basicCount) / ((double) totalCount)) * 100;
+      }
+      boolean value = percentValue >= min.getDoubleValue(element.getParent())
+              && percentValue <= max.getDoubleValue(element.getParent());
+      return new EvaluatedCondition(this, value);
+    } else {
+      boolean value = anchorCount >= min.getIntegerValue(element.getParent())
+              && anchorCount <= max.getIntegerValue(element.getParent());
+      return new EvaluatedCondition(this, value);
+    }
+  }
+
+  public NumberExpression getMin() {
+    return min;
+  }
+
+  public NumberExpression getMax() {
+    return max;
+  }
+
+  public BooleanExpression getPercent() {
+    return percent;
+  }
+
+  public TextMarkerExpression getArg() {
+    return arg;
+  }
+
+  public ListExpression getArgList() {
+    return argList;
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ContainsCondition.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ContainsCondition.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ContextCountCondition.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ContextCountCondition.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ContextCountCondition.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ContextCountCondition.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.condition;
+
+import java.util.List;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.number.NumberExpression;
+import org.apache.uima.textmarker.expression.number.SimpleNumberExpression;
+import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.EvaluatedCondition;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.type.TextMarkerBasic;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class ContextCountCondition extends TypeSentiveCondition {
+
+  private final NumberExpression min;
+
+  private final NumberExpression max;
+
+  private final String var;
+
+  public ContextCountCondition(TypeExpression type, NumberExpression min, NumberExpression max,
+          String var) {
+    super(type);
+    this.min = min == null ? new SimpleNumberExpression(Integer.MIN_VALUE) : min;
+    this.max = max == null ? new SimpleNumberExpression(Integer.MAX_VALUE) : max;
+    this.var = var;
+  }
+
+  @Override
+  public EvaluatedCondition eval(TextMarkerBasic basic, Type matchedType,
+          TextMarkerRuleElement element, TextMarkerStream stream, InferenceCrowd crowd) {
+    List<TextMarkerBasic> annotationsInWindow = null;
+    if (stream.getDocumentAnnotation().getType().equals(type.getType(element.getParent()))) {
+      annotationsInWindow = stream.getBasicsInWindow(stream.getDocumentAnnotation());
+    } else {
+      annotationsInWindow = stream.getAnnotationsOverlappingWindow(basic,
+              type.getType(element.getParent()));
+    }
+    int counter = 0;
+    int count = 0;
+    for (TextMarkerBasic eachBasic : annotationsInWindow) {
+      if (eachBasic.isAnchorOf(matchedType.getName())
+              || stream.getCas().getTypeSystem().subsumes(matchedType, eachBasic.getType())) {
+        counter++;
+        if (eachBasic.equals(basic)) {
+          count = counter;
+          break;
+        }
+      }
+    }
+
+    if (var != null) {
+      element.getParent().getEnvironment().setVariableValue(var, count);
+    }
+    boolean value = count >= min.getIntegerValue(element.getParent())
+            && count <= max.getIntegerValue(element.getParent());
+    return new EvaluatedCondition(this, value);
+  }
+
+  public NumberExpression getMin() {
+    return min;
+  }
+
+  public NumberExpression getMax() {
+    return max;
+  }
+
+  public String getVar() {
+    return var;
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ContextCountCondition.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ContextCountCondition.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/CountCondition.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/CountCondition.java?rev=1157040&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/CountCondition.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/CountCondition.java Fri Aug 12 10:44:04 2011
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.condition;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.TextMarkerExpression;
+import org.apache.uima.textmarker.expression.bool.BooleanExpression;
+import org.apache.uima.textmarker.expression.list.BooleanListExpression;
+import org.apache.uima.textmarker.expression.list.ListExpression;
+import org.apache.uima.textmarker.expression.list.NumberListExpression;
+import org.apache.uima.textmarker.expression.list.StringListExpression;
+import org.apache.uima.textmarker.expression.list.TypeListExpression;
+import org.apache.uima.textmarker.expression.number.NumberExpression;
+import org.apache.uima.textmarker.expression.number.SimpleNumberExpression;
+import org.apache.uima.textmarker.expression.string.StringExpression;
+import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.EvaluatedCondition;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.type.TextMarkerBasic;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class CountCondition extends TypeSentiveCondition {
+
+  private final NumberExpression min;
+
+  private final NumberExpression max;
+
+  private final String var;
+
+  private ListExpression list;
+
+  private TextMarkerExpression arg;
+
+  public CountCondition(TypeExpression type, NumberExpression min, NumberExpression max, String var) {
+    super(type);
+    this.min = min == null ? new SimpleNumberExpression(Integer.MIN_VALUE) : min;
+    this.max = max == null ? new SimpleNumberExpression(Integer.MAX_VALUE) : max;
+    this.var = var;
+  }
+
+  public CountCondition(ListExpression list, TextMarkerExpression a, NumberExpression min,
+          NumberExpression max, String var) {
+    super((TypeExpression) null);
+    this.list = list;
+    this.arg = a;
+    this.min = min == null ? new SimpleNumberExpression(Integer.MIN_VALUE) : min;
+    this.max = max == null ? new SimpleNumberExpression(Integer.MAX_VALUE) : max;
+    this.var = var;
+  }
+
+  @Override
+  public EvaluatedCondition eval(TextMarkerBasic basic, Type matchedType,
+          TextMarkerRuleElement element, TextMarkerStream stream, InferenceCrowd crowd) {
+    if (arg == null) {
+      AnnotationFS annotation = basic.getType(matchedType.getName());
+      List<AnnotationFS> annotationsInWindow = stream.getAnnotationsInWindow(annotation,
+              type.getType(element.getParent()));
+      int count = annotationsInWindow.size();
+      if (var != null) {
+        element.getParent().getEnvironment().setVariableValue(var, count);
+      }
+      boolean value = count >= min.getIntegerValue(element.getParent())
+              && count <= max.getIntegerValue(element.getParent());
+      return new EvaluatedCondition(this, value);
+    } else {
+      int count = 0;
+      if (arg instanceof BooleanExpression && list instanceof BooleanListExpression) {
+        BooleanExpression e = (BooleanExpression) arg;
+        BooleanListExpression le = (BooleanListExpression) list;
+        boolean v = e.getBooleanValue(element.getParent());
+        List<Boolean> l = new ArrayList<Boolean>(le.getList(element.getParent()));
+        while (l.remove(v)) {
+          count++;
+        }
+      } else if (arg instanceof NumberExpression && list instanceof NumberListExpression) {
+        NumberExpression e = (NumberExpression) arg;
+        NumberListExpression le = (NumberListExpression) list;
+        Number v = e.getDoubleValue(element.getParent());
+        List<Number> l = new ArrayList<Number>(le.getList(element.getParent()));
+        while (l.remove(v)) {
+          count++;
+        }
+      } else if (arg instanceof StringExpression && list instanceof StringListExpression) {
+        StringExpression e = (StringExpression) arg;
+        StringListExpression le = (StringListExpression) list;
+        String v = e.getStringValue(element.getParent());
+        List<String> l = new ArrayList<String>(le.getList(element.getParent()));
+        while (l.remove(v)) {
+          count++;
+        }
+      } else if (arg instanceof TypeExpression && list instanceof TypeListExpression) {
+        TypeExpression e = (TypeExpression) arg;
+        TypeListExpression le = (TypeListExpression) list;
+        Type v = e.getType(element.getParent());
+        List<Type> l = new ArrayList<Type>(le.getList(element.getParent()));
+        while (l.remove(v)) {
+          count++;
+        }
+      }
+      boolean value = count >= min.getIntegerValue(element.getParent())
+              && count <= max.getIntegerValue(element.getParent());
+      return new EvaluatedCondition(this, value);
+    }
+  }
+
+  public NumberExpression getMin() {
+    return min;
+  }
+
+  public NumberExpression getMax() {
+    return max;
+  }
+
+  public String getVar() {
+    return var;
+  }
+
+  public ListExpression getArgList() {
+    return list;
+  }
+
+  public TextMarkerExpression getArg() {
+    return arg;
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/CountCondition.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/CountCondition.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain