You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2015/11/06 18:17:45 UTC
svn commit: r1712988 [3/5] - in /uima/ruta/branches/UIMA-4408:
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/fst/
ruta-core-ext/src/main/java/or...
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/IsCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/IsCondition.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/IsCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/IsCondition.java Fri Nov 6 17:17:42 2015
@@ -50,7 +50,7 @@ public class IsCondition extends TypeSen
RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());
if (!isWorkingOnList()) {
Collection<AnnotationFS> beginAnchors = beginAnchor
- .getBeginAnchors(type.getType(element.getParent()));
+ .getBeginAnchors(type.getType(context, stream));
boolean result = false;
if (beginAnchors != null) {
for (AnnotationFS annotationFS : beginAnchors) {
@@ -63,7 +63,7 @@ public class IsCondition extends TypeSen
return new EvaluatedCondition(this, result);
} else {
boolean result = false;
- List<Type> types = getList().getList(element.getParent(), stream);
+ List<Type> types = getList().getList(context, stream);
for (Type type : types) {
Collection<AnnotationFS> beginAnchors = beginAnchor.getBeginAnchors(type);
if (beginAnchors != null) {
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/LastCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/LastCondition.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/LastCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/LastCondition.java Fri Nov 6 17:17:42 2015
@@ -40,7 +40,7 @@ public class LastCondition extends TypeS
AnnotationFS annotation = context.getAnnotation();
RuleElement element = context.getElement();
RutaBasic endAnchor = stream.getEndAnchor(annotation.getEnd());
- Type t = type.getType(element.getParent());
+ Type t = type.getType(context, stream);
boolean result = endAnchor.beginsWith(t) && endAnchor.endsWith(t);
return new EvaluatedCondition(this, result);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/MOfNCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/MOfNCondition.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/MOfNCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/MOfNCondition.java Fri Nov 6 17:17:42 2015
@@ -58,8 +58,8 @@ public class MOfNCondition extends Compo
result++;
}
}
- boolean value = result >= min.getIntegerValue(element.getParent(), annotation, stream)
- && result <= max.getIntegerValue(element.getParent(), annotation, stream);
+ boolean value = result >= min.getIntegerValue(context, stream)
+ && result <= max.getIntegerValue(context, stream);
return new EvaluatedCondition(this, value, evals);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/NearCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/NearCondition.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/NearCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/NearCondition.java Fri Nov 6 17:17:42 2015
@@ -57,11 +57,11 @@ public class NearCondition extends TypeS
public EvaluatedCondition eval(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
AnnotationFS annotation = context.getAnnotation();
RuleElement element = context.getElement();
- int maxValue = max.getIntegerValue(element.getParent(), annotation, stream);
- int minValue = min.getIntegerValue(element.getParent(), annotation, stream);
- boolean forwardValue = forward.getBooleanValue(element.getParent(), annotation, stream);
+ int maxValue = max.getIntegerValue(context, stream);
+ int minValue = min.getIntegerValue(context, stream);
+ boolean forwardValue = forward.getBooleanValue(context, stream);
- FSIterator<AnnotationFS> it = filtered.getBooleanValue(element.getParent(), annotation, stream) ? stream
+ FSIterator<AnnotationFS> it = filtered.getBooleanValue(context, stream) ? stream
: stream.getUnfilteredBasicIterator();
AnnotationFS pointer = null;
if (forwardValue) {
@@ -76,7 +76,7 @@ public class NearCondition extends TypeS
FeatureStructure featureStructure = it.get();
if (featureStructure instanceof RutaBasic) {
RutaBasic each = (RutaBasic) featureStructure;
- if (each.isPartOf(type.getType(element.getParent()))) {
+ if (each.isPartOf(type.getType(context, stream))) {
return new EvaluatedCondition(this, true);
}
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/ParseCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/ParseCondition.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/ParseCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/ParseCondition.java Fri Nov 6 17:17:42 2015
@@ -59,7 +59,7 @@ public class ParseCondition extends Abst
NumberFormat nf = null;
String locale = annotation.getCAS().getDocumentLanguage();
if(localeExpr != null) {
- locale = localeExpr.getStringValue(element.getParent(), annotation, stream);
+ locale = localeExpr.getStringValue(context, stream);
}
if(locale == null) {
locale = "x-unspecified";
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfCondition.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfCondition.java Fri Nov 6 17:17:42 2015
@@ -48,12 +48,12 @@ public class PartOfCondition extends Typ
AnnotationFS annotation = context.getAnnotation();
RuleElement element = context.getElement();
if (!isWorkingOnList()) {
- Type t = type.getType(element.getParent());
+ Type t = type.getType(context, stream);
boolean result = check(t, annotation, element, stream);
return new EvaluatedCondition(this, result);
} else {
boolean result = false;
- List<Type> types = getList().getList(element.getParent(), stream);
+ List<Type> types = getList().getList(context, stream);
for (Type t : types) {
result |= check(t, annotation, element, stream);
if (result == true) {
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfNeqCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfNeqCondition.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfNeqCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfNeqCondition.java Fri Nov 6 17:17:42 2015
@@ -48,12 +48,12 @@ public class PartOfNeqCondition extends
AnnotationFS annotation = context.getAnnotation();
RuleElement element = context.getElement();
if (!isWorkingOnList()) {
- Type t = type.getType(element.getParent());
+ Type t = type.getType(context, stream);
boolean result = check(annotation, stream, t);
return new EvaluatedCondition(this, result);
} else {
boolean result = false;
- List<Type> types = getList().getList(element.getParent(), stream);
+ List<Type> types = getList().getList(context, stream);
for (Type t : types) {
result |= check(annotation, stream, t);
if (result == true) {
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/PositionCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/PositionCondition.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/PositionCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/PositionCondition.java Fri Nov 6 17:17:42 2015
@@ -53,7 +53,7 @@ public class PositionCondition extends T
public EvaluatedCondition eval(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
AnnotationFS annotation = context.getAnnotation();
RuleElement element = context.getElement();
- Type t = type.getType(element.getParent());
+ Type t = type.getType(context, stream);
RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());
RutaBasic endAnchor = stream.getEndAnchor(annotation.getEnd());
@@ -62,8 +62,8 @@ public class PositionCondition extends T
return new EvaluatedCondition(this, false);
}
- boolean relatively = relative == null ? true : relative.getBooleanValue(element.getParent(),
- annotation, stream);
+ boolean relatively = relative == null ? true : relative.getBooleanValue(context,
+ stream);
FSIterator<AnnotationFS> iterator = stream.getCas().getAnnotationIndex(t).iterator(beginAnchor);
if (!iterator.isValid()) {
@@ -94,7 +94,7 @@ public class PositionCondition extends T
if (window == null) {
return new EvaluatedCondition(this, false);
}
- int integerValue = position.getIntegerValue(element.getParent(), annotation, stream);
+ int integerValue = position.getIntegerValue(context, stream);
if (relatively) {
int counter = 0;
List<RutaBasic> inWindow = stream.getBasicsInWindow(window);
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/RegExpCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/RegExpCondition.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/RegExpCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/RegExpCondition.java Fri Nov 6 17:17:42 2015
@@ -55,9 +55,9 @@ public class RegExpCondition extends Ter
AnnotationFS annotation = context.getAnnotation();
RuleElement element = context.getElement();
Matcher matcher = null;
- boolean ignore = ignoreCase == null ? false : ignoreCase.getBooleanValue(element.getParent(),
- annotation, stream);
- String stringValue = pattern.getStringValue(element.getParent(), annotation, stream);
+ boolean ignore = ignoreCase == null ? false : ignoreCase.getBooleanValue(context,
+ stream);
+ String stringValue = pattern.getStringValue(context, stream);
if (variable == null) {
String coveredText = annotation.getCoveredText();
Pattern regularExpPattern = null;
@@ -68,7 +68,7 @@ public class RegExpCondition extends Ter
}
matcher = regularExpPattern.matcher(coveredText);
} else {
- String variableValue = variable.getStringValue(element.getParent(), annotation, stream);
+ String variableValue = variable.getStringValue(context, stream);
if(variableValue == null) {
return new EvaluatedCondition(this, false);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/ScoreCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/ScoreCondition.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/ScoreCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/ScoreCondition.java Fri Nov 6 17:17:42 2015
@@ -65,8 +65,8 @@ public class ScoreCondition extends Term
if (var != null) {
element.getParent().getEnvironment().setVariableValue(var, score);
}
- boolean value = score >= min.getDoubleValue(element.getParent(), annotation, stream)
- && score <= max.getDoubleValue(element.getParent(), annotation, stream);
+ boolean value = score >= min.getDoubleValue(context, stream)
+ && score <= max.getDoubleValue(context, stream);
return new EvaluatedCondition(this, value);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/SizeCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/SizeCondition.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/SizeCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/SizeCondition.java Fri Nov 6 17:17:42 2015
@@ -52,9 +52,9 @@ public class SizeCondition extends Abstr
public EvaluatedCondition eval(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
AnnotationFS annotation = context.getAnnotation();
RuleElement element = context.getElement();
- int count = listExpr.getList(element.getParent(), stream).size();
- boolean value = count >= minExpr.getIntegerValue(element.getParent(), annotation, stream)
- && count <= maxExpr.getIntegerValue(element.getParent(), annotation, stream);
+ int count = listExpr.getList(context, stream).size();
+ boolean value = count >= minExpr.getIntegerValue(context, stream)
+ && count <= maxExpr.getIntegerValue(context, stream);
if (varExpr != null) {
element.getParent().getEnvironment().setVariableValue(varExpr, count);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/StartsWithCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/StartsWithCondition.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/StartsWithCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/StartsWithCondition.java Fri Nov 6 17:17:42 2015
@@ -49,12 +49,12 @@ public class StartsWithCondition extends
// TODO rewrite
if (!isWorkingOnList()) {
- Type t = type.getType(element.getParent());
+ Type t = type.getType(context, stream);
boolean result = check(annotation, t, stream);
return new EvaluatedCondition(this, result);
} else {
boolean result = false;
- List<Type> types = getList().getList(element.getParent(), stream);
+ List<Type> types = getList().getList(context, stream);
for (Type t : types) {
result |= check(annotation, t, stream);
if (result == true) {
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/TotalCountCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/TotalCountCondition.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/TotalCountCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/TotalCountCondition.java Fri Nov 6 17:17:42 2015
@@ -52,14 +52,14 @@ public class TotalCountCondition extends
AnnotationFS annotation = context.getAnnotation();
RuleElement element = context.getElement();
int count = 0;
- Type t = type.getType(element.getParent());
+ Type t = type.getType(context, stream);
AnnotationIndex<Annotation> annotationIndex = stream.getJCas().getAnnotationIndex(t);
count= annotationIndex.size();
if (var != null) {
element.getParent().getEnvironment().setVariableValue(var, count);
}
- boolean value = count >= min.getIntegerValue(element.getParent(), annotation, stream)
- && count <= max.getIntegerValue(element.getParent(), annotation, stream);
+ boolean value = count >= min.getIntegerValue(context, stream)
+ && count <= max.getIntegerValue(context, stream);
return new EvaluatedCondition(this, value);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/VoteCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/VoteCondition.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/VoteCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/VoteCondition.java Fri Nov 6 17:17:42 2015
@@ -51,8 +51,8 @@ public class VoteCondition extends Termi
int count2 = 0;
if (annotation != null) {
List<RutaBasic> annotations = stream.getBasicsInWindow(annotation);
- Type t1 = type1.getType(element.getParent());
- Type t2 = type2.getType(element.getParent());
+ Type t1 = type1.getType(context, stream);
+ Type t2 = type2.getType(context, stream);
for (RutaBasic each : annotations) {
if (each.beginsWith(t1)) {
count1++;
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/MatchReference.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/MatchReference.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/MatchReference.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/MatchReference.java Fri Nov 6 17:17:42 2015
@@ -24,12 +24,14 @@ import java.util.List;
import org.apache.uima.ruta.RutaBlock;
import org.apache.uima.ruta.RutaEnvironment;
+import org.apache.uima.ruta.RutaStream;
import org.apache.uima.ruta.expression.feature.FeatureExpression;
import org.apache.uima.ruta.expression.feature.FeatureMatchExpression;
import org.apache.uima.ruta.expression.feature.SimpleFeatureExpression;
import org.apache.uima.ruta.expression.type.SimpleTypeExpression;
import org.apache.uima.ruta.expression.type.TypeExpression;
import org.apache.uima.ruta.expression.type.TypeVariableExpression;
+import org.apache.uima.ruta.rule.MatchContext;
public class MatchReference extends RutaExpression {
@@ -55,10 +57,11 @@ public class MatchReference extends Ruta
this.typeExpression = expression;
}
- private void resolve(RutaBlock parent) {
+ private void resolve(MatchContext context, RutaStream stream) {
if (typeExpression != null) {
return;
}
+ RutaBlock parent = context.getParent();
RutaEnvironment e = parent.getEnvironment();
typeExpression = buildTypeExpression(match, e);
if (typeExpression == null) {
@@ -88,7 +91,7 @@ public class MatchReference extends Ruta
}
}
}
- if(typeExpression == null || typeExpression.getType(parent) == null) {
+ if(typeExpression == null || typeExpression.getType(context, stream) == null) {
throw new IllegalArgumentException("Not able to resolve type of expression: "+ match);
}
}
@@ -102,13 +105,13 @@ public class MatchReference extends Ruta
return null;
}
- public TypeExpression getTypeExpression(RutaBlock parent) {
- resolve(parent);
+ public TypeExpression getTypeExpression(MatchContext context, RutaStream stream) {
+ resolve(context, stream);
return typeExpression;
}
- public FeatureExpression getFeatureExpression(RutaBlock parent) {
- resolve(parent);
+ public FeatureExpression getFeatureExpression(MatchContext context, RutaStream stream) {
+ resolve(context, stream);
return featureExpression;
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/NullExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/NullExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/NullExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/NullExpression.java Fri Nov 6 17:17:42 2015
@@ -31,50 +31,50 @@ import org.apache.uima.ruta.expression.f
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.MatchContext;
import org.apache.uima.ruta.rule.RuleElement;
import org.apache.uima.ruta.rule.RuleMatch;
public class NullExpression extends FeatureExpression implements IStringExpression, ITypeExpression{
@Override
- public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
+ public String getStringValue(MatchContext context, RutaStream stream) {
return null;
}
+
@Override
- public String getStringValue(RutaBlock parent, RuleMatch match, RuleElement element,
- RutaStream stream) {
+ public Collection<AnnotationFS> getFeatureAnnotations(Collection<AnnotationFS> annotations,
+ RutaStream stream, MatchContext context, boolean checkOnFeatureValue) {
return null;
}
@Override
- public Feature getFeature(RutaBlock parent) {
+ public Type getType(MatchContext context, RutaStream stream) {
return null;
}
- @Override
- public List<Feature> getFeatures(RutaBlock parent) {
- return null;
- }
@Override
- public List<String> getFeatureStringList(RutaBlock parent) {
+ public Feature getFeature(MatchContext context, RutaStream stream) {
return null;
}
+
@Override
- public TypeExpression getTypeExpr(RutaBlock parent) {
+ public List<Feature> getFeatures(MatchContext context, RutaStream stream) {
return null;
}
+
@Override
- public Collection<AnnotationFS> getFeatureAnnotations(Collection<AnnotationFS> annotations,
- RutaStream stream, RutaBlock parent, boolean checkOnFeatureValue) {
+ public List<String> getFeatureStringList(MatchContext context, RutaStream stream) {
return null;
}
+
@Override
- public Type getType(RutaBlock parent) {
+ public TypeExpression getTypeExpr(MatchContext context, RutaStream stream) {
return null;
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/AbstractAnnotationExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/AbstractAnnotationExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/AbstractAnnotationExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/AbstractAnnotationExpression.java Fri Nov 6 17:17:42 2015
@@ -29,29 +29,4 @@ import org.apache.uima.ruta.rule.RuleMat
public abstract class AbstractAnnotationExpression implements IAnnotationExpression {
- public AnnotationFS getAnnotation(RutaBlock parent, RuleMatch match, RuleElement element,
- RutaStream stream) {
- List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOfElement(element);
- // TODO: do we need to select the correct annotation?
- AnnotationFS annotation = null;
- if (!matchedAnnotationsOf.isEmpty()) {
- annotation = matchedAnnotationsOf.get(0);
- }
- return getAnnotation(parent, annotation, stream);
- }
-
- public abstract AnnotationFS getAnnotation(RutaBlock parent, AnnotationFS annotation, RutaStream stream);
-
- public List<AnnotationFS> getAnnotations(RutaBlock parent, RuleMatch match, RuleElement element,
- RutaStream stream) {
- List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOfElement(element);
- // TODO: do we need to select the correct annotation?
- AnnotationFS annotation = null;
- if (!matchedAnnotationsOf.isEmpty()) {
- annotation = matchedAnnotationsOf.get(0);
- }
- return getAnnotations(parent, annotation, stream);
- }
-
- public abstract List<AnnotationFS> getAnnotations(RutaBlock parent, AnnotationFS annotation, RutaStream stream);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/IAnnotationExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/IAnnotationExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/IAnnotationExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/IAnnotationExpression.java Fri Nov 6 17:17:42 2015
@@ -24,6 +24,7 @@ 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.rule.MatchContext;
import org.apache.uima.ruta.rule.RuleElement;
import org.apache.uima.ruta.rule.RuleMatch;
@@ -34,13 +35,6 @@ import org.apache.uima.ruta.rule.RuleMat
*/
public interface IAnnotationExpression {
- AnnotationFS getAnnotation(RutaBlock parent, AnnotationFS annotation, RutaStream stream);
-
- List<AnnotationFS> getAnnotations(RutaBlock parent, AnnotationFS annotation, RutaStream stream);
-
- AnnotationFS getAnnotation(RutaBlock parent, RuleMatch match, RuleElement element, RutaStream stream);
-
- List<AnnotationFS> getAnnotations(RutaBlock parent, RuleMatch match, RuleElement element,
- RutaStream stream);
+ AnnotationFS getAnnotation(MatchContext context, RutaStream stream);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/LabelAnnotationExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/LabelAnnotationExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/LabelAnnotationExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/LabelAnnotationExpression.java Fri Nov 6 17:17:42 2015
@@ -24,19 +24,16 @@ 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.rule.MatchContext;
public class LabelAnnotationExpression extends AbstractAnnotationExpression {
- @Override
- public AnnotationFS getAnnotation(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- // TODO
- return getAnnotations(parent, annotation, stream).get(0);
- }
@Override
- public List<AnnotationFS> getAnnotations(RutaBlock parent, AnnotationFS annotation,
- RutaStream stream) {
+ public AnnotationFS getAnnotation(MatchContext context, RutaStream stream) {
+ // TODO Auto-generated method stub
return null;
}
+
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/AbstractBooleanExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/AbstractBooleanExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/AbstractBooleanExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/AbstractBooleanExpression.java Fri Nov 6 17:17:42 2015
@@ -25,23 +25,10 @@ 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.AbstractStringExpression;
+import org.apache.uima.ruta.rule.MatchContext;
import org.apache.uima.ruta.rule.RuleElement;
import org.apache.uima.ruta.rule.RuleMatch;
public abstract class AbstractBooleanExpression extends AbstractStringExpression implements IBooleanExpression {
- public boolean getBooleanValue(RutaBlock parent, RuleMatch match, RuleElement element,
- RutaStream stream) {
- List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOfElement(element);
- // TODO: do we need to select the correct annotation?
- AnnotationFS annotation = null;
- if (!matchedAnnotationsOf.isEmpty()) {
- annotation = matchedAnnotationsOf.get(0);
- }
- return getBooleanValue(parent, annotation, stream);
- }
-
- public abstract boolean getBooleanValue(RutaBlock parent, AnnotationFS annotation,
- RutaStream stream);
-
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanFeatureExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanFeatureExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanFeatureExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanFeatureExpression.java Fri Nov 6 17:17:42 2015
@@ -28,6 +28,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.feature.FeatureExpression;
+import org.apache.uima.ruta.rule.MatchContext;
public class BooleanFeatureExpression extends AbstractBooleanExpression {
@@ -39,11 +40,13 @@ public class BooleanFeatureExpression ex
}
@Override
- public boolean getBooleanValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- Type type = fe.getTypeExpr(parent).getType(parent);
- Feature feature = fe.getFeature(parent);
+ public boolean getBooleanValue(MatchContext context, RutaStream stream) {
+ AnnotationFS annotation = context.getAnnotation();
+ RutaBlock parent = context.getParent();
+ Type type = fe.getTypeExpr(context, stream).getType(context, stream);
+ Feature feature = fe.getFeature(context, stream);
List<AnnotationFS> list = getTargetAnnotation(annotation, type, stream);
- Collection<AnnotationFS> featureAnnotations = fe.getFeatureAnnotations(list, stream, parent,
+ Collection<AnnotationFS> featureAnnotations = fe.getFeatureAnnotations(list, stream, context,
false);
if (!featureAnnotations.isEmpty()) {
AnnotationFS next = featureAnnotations.iterator().next();
@@ -53,8 +56,8 @@ public class BooleanFeatureExpression ex
}
@Override
- public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- return String.valueOf(getBooleanValue(parent, annotation, stream));
+ public String getStringValue(MatchContext context, RutaStream stream) {
+ return String.valueOf(getBooleanValue(context, stream));
}
public FeatureExpression getFe() {
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanNumberExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanNumberExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanNumberExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanNumberExpression.java Fri Nov 6 17:17:42 2015
@@ -23,6 +23,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.number.INumberExpression;
+import org.apache.uima.ruta.rule.MatchContext;
public class BooleanNumberExpression extends AbstractBooleanExpression {
@@ -40,9 +41,11 @@ public class BooleanNumberExpression ext
}
@Override
- public boolean getBooleanValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- double doubleValue1 = getFristExpression().getDoubleValue(parent, annotation, stream);
- double doubleValue2 = getSecondExpression().getDoubleValue(parent, annotation, stream);
+ public boolean getBooleanValue(MatchContext context, RutaStream stream) {
+ AnnotationFS annotation = context.getAnnotation();
+ RutaBlock parent = context.getParent();
+ double doubleValue1 = getFristExpression().getDoubleValue(context, stream);
+ double doubleValue2 = getSecondExpression().getDoubleValue(context, stream);
return eval(doubleValue1, getOperator(), doubleValue2);
}
@@ -76,9 +79,9 @@ public class BooleanNumberExpression ext
}
@Override
- public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- return e1.getStringValue(parent, annotation, stream) + " " + op + " "
- + e2.getStringValue(parent, annotation, stream);
+ public String getStringValue(MatchContext context, RutaStream stream) {
+ return e1.getStringValue(context, stream) + " " + op + " "
+ + e2.getStringValue(context, stream);
}
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanTypeExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanTypeExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanTypeExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanTypeExpression.java Fri Nov 6 17:17:42 2015
@@ -24,6 +24,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.type.TypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
public class BooleanTypeExpression extends AbstractBooleanExpression {
@@ -41,10 +42,12 @@ public class BooleanTypeExpression exten
}
@Override
- public boolean getBooleanValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- Type type1 = getFristExpression().getType(parent);
+ public boolean getBooleanValue(MatchContext context, RutaStream stream) {
+ AnnotationFS annotation = context.getAnnotation();
+ RutaBlock parent = context.getParent();
+ Type type1 = getFristExpression().getType(context, stream);
String first = type1.getName();
- Type type2 = getSecondExpression().getType(parent);
+ Type type2 = getSecondExpression().getType(context, stream);
String second = type2.getName();
return eval(first, getOperator(), second);
}
@@ -71,9 +74,9 @@ public class BooleanTypeExpression exten
}
@Override
- public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- return e1.getStringValue(parent, annotation, stream) + " " + op + " "
- + e2.getStringValue(parent, annotation, stream);
+ public String getStringValue(MatchContext context, RutaStream stream) {
+ return e1.getStringValue(context, stream) + " " + op + " "
+ + e2.getStringValue(context, stream);
}
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanVariableExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanVariableExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanVariableExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/BooleanVariableExpression.java Fri Nov 6 17:17:42 2015
@@ -22,6 +22,7 @@ package org.apache.uima.ruta.expression.
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.ruta.RutaBlock;
import org.apache.uima.ruta.RutaStream;
+import org.apache.uima.ruta.rule.MatchContext;
public class BooleanVariableExpression extends AbstractBooleanExpression {
@@ -33,7 +34,9 @@ public class BooleanVariableExpression e
}
@Override
- public boolean getBooleanValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
+ public boolean getBooleanValue(MatchContext context, RutaStream stream) {
+ AnnotationFS annotation = context.getAnnotation();
+ RutaBlock parent = context.getParent();
Boolean variableValue = parent.getEnvironment().getVariableValue(var, Boolean.class);
if (variableValue == null) {
return false;
@@ -46,8 +49,8 @@ public class BooleanVariableExpression e
}
@Override
- public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- return getBooleanValue(parent, annotation, stream) ? "true" : "false";
+ public String getStringValue(MatchContext context, RutaStream stream) {
+ return getBooleanValue(context, stream) ? "true" : "false";
}
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/IBooleanExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/IBooleanExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/IBooleanExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/IBooleanExpression.java Fri Nov 6 17:17:42 2015
@@ -19,17 +19,15 @@
package org.apache.uima.ruta.expression.bool;
-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.string.IStringExpression;
+import org.apache.uima.ruta.rule.MatchContext;
import org.apache.uima.ruta.rule.RuleElement;
import org.apache.uima.ruta.rule.RuleMatch;
public interface IBooleanExpression extends IStringExpression {
- boolean getBooleanValue(RutaBlock parent, RuleMatch match, RuleElement element, RutaStream stream);
-
- boolean getBooleanValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream);
+ boolean getBooleanValue(MatchContext context, RutaStream stream);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/SimpleBooleanExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/SimpleBooleanExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/SimpleBooleanExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/SimpleBooleanExpression.java Fri Nov 6 17:17:42 2015
@@ -19,9 +19,8 @@
package org.apache.uima.ruta.expression.bool;
-import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.ruta.RutaBlock;
import org.apache.uima.ruta.RutaStream;
+import org.apache.uima.ruta.rule.MatchContext;
public class SimpleBooleanExpression extends AbstractBooleanExpression {
@@ -33,7 +32,7 @@ public class SimpleBooleanExpression ext
}
@Override
- public boolean getBooleanValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
+ public boolean getBooleanValue(MatchContext context, RutaStream stream) {
return getPrimitiveValue();
}
@@ -42,8 +41,8 @@ public class SimpleBooleanExpression ext
}
@Override
- public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- return getBooleanValue(parent, annotation, stream) ? "true" : "false";
+ public String getStringValue(MatchContext context, RutaStream stream) {
+ return getBooleanValue(context, stream) ? "true" : "false";
}
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/SimpleBooleanFunction.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/SimpleBooleanFunction.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/SimpleBooleanFunction.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/bool/SimpleBooleanFunction.java Fri Nov 6 17:17:42 2015
@@ -19,9 +19,8 @@
package org.apache.uima.ruta.expression.bool;
-import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.ruta.RutaBlock;
import org.apache.uima.ruta.RutaStream;
+import org.apache.uima.ruta.rule.MatchContext;
public class SimpleBooleanFunction extends AbstractBooleanExpression {
@@ -39,9 +38,9 @@ public class SimpleBooleanFunction exten
}
@Override
- public boolean getBooleanValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- boolean b1 = e1.getBooleanValue(parent, annotation, stream);
- boolean b2 = e2.getBooleanValue(parent, annotation, stream);
+ public boolean getBooleanValue(MatchContext context, RutaStream stream) {
+ boolean b1 = e1.getBooleanValue(context, stream);
+ boolean b2 = e2.getBooleanValue(context, stream);
if ("XOR".equals(op)) {
return (b1 || b2) && !(b1 && b2);
} else if ("==".equals(op)) {
@@ -53,9 +52,9 @@ public class SimpleBooleanFunction exten
}
@Override
- public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- return e1.getStringValue(parent, annotation, stream) + " " + op + " "
- + e2.getStringValue(parent, annotation, stream);
+ public String getStringValue(MatchContext context, RutaStream stream) {
+ return e1.getStringValue(context, stream) + " " + op + " "
+ + e2.getStringValue(context, stream);
}
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/FeatureExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/FeatureExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/FeatureExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/FeatureExpression.java Fri Nov 6 17:17:42 2015
@@ -28,19 +28,20 @@ import org.apache.uima.ruta.RutaBlock;
import org.apache.uima.ruta.RutaStream;
import org.apache.uima.ruta.expression.RutaExpression;
import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
public abstract class FeatureExpression extends RutaExpression {
- public abstract Feature getFeature(RutaBlock parent);
+ public abstract Feature getFeature(MatchContext context, RutaStream stream);
- public abstract List<Feature> getFeatures(RutaBlock parent);
+ public abstract List<Feature> getFeatures(MatchContext context, RutaStream stream);
- public abstract List<String> getFeatureStringList(RutaBlock parent);
+ public abstract List<String> getFeatureStringList(MatchContext context, RutaStream stream);
- public abstract TypeExpression getTypeExpr(RutaBlock parent);
+ public abstract TypeExpression getTypeExpr(MatchContext context, RutaStream stream);
public abstract Collection<AnnotationFS> getFeatureAnnotations(
- Collection<AnnotationFS> annotations, RutaStream stream, RutaBlock parent,
+ Collection<AnnotationFS> annotations, RutaStream stream, MatchContext context,
boolean checkOnFeatureValue);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/FeatureMatchExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/FeatureMatchExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/FeatureMatchExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/FeatureMatchExpression.java Fri Nov 6 17:17:42 2015
@@ -35,6 +35,7 @@ import org.apache.uima.ruta.expression.R
import org.apache.uima.ruta.expression.bool.IBooleanExpression;
import org.apache.uima.ruta.expression.number.INumberExpression;
import org.apache.uima.ruta.expression.string.IStringExpression;
+import org.apache.uima.ruta.rule.MatchContext;
public class FeatureMatchExpression extends SimpleFeatureExpression {
@@ -48,7 +49,8 @@ public class FeatureMatchExpression exte
public FeatureMatchExpression(FeatureExpression f, String op, IRutaExpression arg,
RutaBlock parent) {
- super(f.getTypeExpr(parent), f.getFeatureStringList(parent));
+ // FIXME
+ super(f.getTypeExpr(new MatchContext(parent), null), f.getFeatureStringList(new MatchContext(parent), null));
this.op = op;
this.arg = arg;
}
@@ -79,20 +81,19 @@ public class FeatureMatchExpression exte
this.op = op;
}
- public boolean checkFeatureValue(AnnotationFS afs, RutaStream stream, RutaBlock parent) {
- Feature feature = getFeature(parent);
- return checkFeatureValue(afs, feature, stream, parent);
+ public boolean checkFeatureValue( AnnotationFS afs, MatchContext context, RutaStream stream) {
+ Feature feature = getFeature(context, stream);
+ return checkFeatureValue(afs, context, feature, stream);
}
- public boolean checkFeatureValue(AnnotationFS afs, Feature feature, RutaStream stream,
- RutaBlock parent) {
+ public boolean checkFeatureValue(AnnotationFS afs, MatchContext context, Feature feature, RutaStream stream) {
// null is possibly coveredText
String rn = feature == null ? UIMAConstants.TYPE_STRING : feature.getRange().getName();
if (rn.equals(UIMAConstants.TYPE_BOOLEAN)) {
Boolean v1 = afs.getBooleanValue(feature);
if (getArg() instanceof IBooleanExpression) {
IBooleanExpression expr = (IBooleanExpression) getArg();
- Boolean v2 = expr.getBooleanValue(parent, afs, stream);
+ Boolean v2 = expr.getBooleanValue(context, stream);
return compare(v1, v2);
}
} else if (rn.equals(UIMAConstants.TYPE_INTEGER) || rn.equals(UIMAConstants.TYPE_BYTE)
@@ -100,21 +101,21 @@ public class FeatureMatchExpression exte
Integer v1 = afs.getIntValue(feature);
if (getArg() instanceof INumberExpression) {
INumberExpression expr = (INumberExpression) getArg();
- Integer v2 = expr.getIntegerValue(parent, afs, stream);
+ Integer v2 = expr.getIntegerValue(context, stream);
return compare(v1, v2);
}
} else if (rn.equals(UIMAConstants.TYPE_DOUBLE)) {
Double v1 = afs.getDoubleValue(feature);
if (getArg() instanceof INumberExpression) {
INumberExpression expr = (INumberExpression) getArg();
- Double v2 = expr.getDoubleValue(parent, afs, stream);
+ Double v2 = expr.getDoubleValue(context, stream);
return compare(v1, v2);
}
} else if (rn.equals(UIMAConstants.TYPE_FLOAT)) {
Float v1 = afs.getFloatValue(feature);
if (getArg() instanceof INumberExpression) {
INumberExpression expr = (INumberExpression) getArg();
- Float v2 = expr.getFloatValue(parent, afs, stream);
+ Float v2 = expr.getFloatValue(context, stream);
return compare(v1, v2);
}
} else if (rn.equals(UIMAConstants.TYPE_STRING)) {
@@ -125,14 +126,14 @@ public class FeatureMatchExpression exte
}
if (getArg() instanceof IStringExpression) {
IStringExpression expr = (IStringExpression) getArg();
- String v2 = expr.getStringValue(parent, afs, stream);
+ String v2 = expr.getStringValue(context, stream);
return compare(v1, v2);
}
} else if (!feature.getRange().isPrimitive() && getArg() instanceof FeatureExpression) {
FeatureExpression fe = (FeatureExpression) getArg();
List<AnnotationFS> list = new ArrayList<AnnotationFS>(1);
list.add(afs);
- Collection<AnnotationFS> featureAnnotations = fe.getFeatureAnnotations(list, stream, parent,
+ Collection<AnnotationFS> featureAnnotations = fe.getFeatureAnnotations(list, stream, context,
false);
return compare(afs.getFeatureValue(feature), featureAnnotations);
}
@@ -188,4 +189,5 @@ public class FeatureMatchExpression exte
return false;
}
+
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/GenericFeatureExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/GenericFeatureExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/GenericFeatureExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/GenericFeatureExpression.java Fri Nov 6 17:17:42 2015
@@ -19,7 +19,6 @@
package org.apache.uima.ruta.expression.feature;
-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.ExpressionFactory;
@@ -27,106 +26,70 @@ import org.apache.uima.ruta.expression.R
import org.apache.uima.ruta.expression.bool.IBooleanExpression;
import org.apache.uima.ruta.expression.number.INumberExpression;
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;
-public class GenericFeatureExpression extends RutaExpression implements INumberExpression, IBooleanExpression, IStringExpression {
+public class GenericFeatureExpression extends RutaExpression implements INumberExpression,
+ IBooleanExpression, IStringExpression {
private FeatureExpression featureExpression;
private INumberExpression numberExpression;
-
+
private IStringExpression stringExpression;
-
+
private IBooleanExpression booleanExpression;
-
+
public GenericFeatureExpression(FeatureExpression fe) {
super();
this.featureExpression = fe;
}
-
-
- public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- if(stringExpression == null) {
- stringExpression = ExpressionFactory.createStringFeatureExpression(featureExpression);
- }
- return stringExpression.getStringValue(parent, annotation, stream);
- }
- public String getStringValue(RutaBlock parent, RuleMatch match, RuleElement element,
- RutaStream stream) {
- if(stringExpression == null) {
+ @Override
+ public String getStringValue(MatchContext context, RutaStream stream) {
+ if (stringExpression == null) {
stringExpression = ExpressionFactory.createStringFeatureExpression(featureExpression);
}
- return stringExpression.getStringValue(parent, match, element, stream);
+ return stringExpression.getStringValue(context, stream);
}
- public boolean getBooleanValue(RutaBlock parent, RuleMatch match, RuleElement element,
- RutaStream stream) {
- if(booleanExpression == null) {
+ @Override
+ public boolean getBooleanValue(MatchContext context, RutaStream stream) {
+ if (booleanExpression == null) {
booleanExpression = ExpressionFactory.createBooleanFeatureExpression(featureExpression);
}
- return booleanExpression.getBooleanValue(parent, match, element, stream);
- }
-
- public boolean getBooleanValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- if(booleanExpression == null) {
- booleanExpression = ExpressionFactory.createBooleanFeatureExpression(featureExpression);
- }
- return booleanExpression.getBooleanValue(parent, annotation, stream);
- }
-
- public int getIntegerValue(RutaBlock parent, RuleMatch match, RuleElement element,
- RutaStream stream) {
- if(numberExpression == null) {
- numberExpression = ExpressionFactory.createNumberFeatureExpression(featureExpression);
- }
- return numberExpression.getIntegerValue(parent, match, element, stream);
- }
-
- public double getDoubleValue(RutaBlock parent, RuleMatch match, RuleElement element,
- RutaStream stream) {
- if(numberExpression == null) {
- numberExpression = ExpressionFactory.createNumberFeatureExpression(featureExpression);
- }
- return numberExpression.getDoubleValue(parent, match, element, stream);
+ return booleanExpression.getBooleanValue(context, stream);
}
- public float getFloatValue(RutaBlock parent, RuleMatch match, RuleElement element,
- RutaStream stream) {
- if(numberExpression == null) {
+ @Override
+ public int getIntegerValue(MatchContext context, RutaStream stream) {
+ if (numberExpression == null) {
numberExpression = ExpressionFactory.createNumberFeatureExpression(featureExpression);
}
- return numberExpression.getFloatValue(parent, match, element, stream);
+ return numberExpression.getIntegerValue(context, stream);
}
- public int getIntegerValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- if(numberExpression == null) {
+ @Override
+ public double getDoubleValue(MatchContext context, RutaStream stream) {
+ if (numberExpression == null) {
numberExpression = ExpressionFactory.createNumberFeatureExpression(featureExpression);
}
- return numberExpression.getIntegerValue(parent, annotation, stream);
+ return numberExpression.getDoubleValue(context, stream);
}
- public double getDoubleValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- if(numberExpression == null) {
+ @Override
+ public float getFloatValue(MatchContext context, RutaStream stream) {
+ if (numberExpression == null) {
numberExpression = ExpressionFactory.createNumberFeatureExpression(featureExpression);
}
- return numberExpression.getDoubleValue(parent, annotation, stream);
+ return numberExpression.getFloatValue(context, stream);
}
- public float getFloatValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- if(numberExpression == null) {
- numberExpression = ExpressionFactory.createNumberFeatureExpression(featureExpression);
- }
- return numberExpression.getFloatValue(parent, annotation, stream);
- }
-
-
public FeatureExpression getFeatureExpression() {
return featureExpression;
}
-
public void setFeatureExpression(FeatureExpression featureExpression) {
this.featureExpression = featureExpression;
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/SimpleFeatureExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/SimpleFeatureExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/SimpleFeatureExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/SimpleFeatureExpression.java Fri Nov 6 17:17:42 2015
@@ -37,6 +37,7 @@ import org.apache.uima.ruta.expression.M
import org.apache.uima.ruta.expression.NullExpression;
import org.apache.uima.ruta.expression.type.TypeExpression;
import org.apache.uima.ruta.rule.AnnotationComparator;
+import org.apache.uima.ruta.rule.MatchContext;
public class SimpleFeatureExpression extends FeatureExpression {
@@ -60,8 +61,8 @@ public class SimpleFeatureExpression ext
}
@Override
- public Feature getFeature(RutaBlock parent) {
- List<Feature> features = getFeatures(parent);
+ public Feature getFeature(MatchContext context, RutaStream stream) {
+ List<Feature> features = getFeatures(context, stream);
if (features != null && !features.isEmpty()) {
return features.get(features.size() - 1);
} else {
@@ -70,17 +71,17 @@ public class SimpleFeatureExpression ext
}
@Override
- public List<Feature> getFeatures(RutaBlock parent) {
+ public List<Feature> getFeatures(MatchContext context, RutaStream stream) {
if (mr != null) {
- typeExpr = mr.getTypeExpression(parent);
- FeatureExpression featureExpression = mr.getFeatureExpression(parent);
+ typeExpr = mr.getTypeExpression(context, stream);
+ FeatureExpression featureExpression = mr.getFeatureExpression(context, stream);
if (featureExpression == null) {
return null;
}
- features = featureExpression.getFeatureStringList(parent);
+ features = featureExpression.getFeatureStringList(context, stream);
}
List<Feature> result = new ArrayList<Feature>();
- Type type = typeExpr.getType(parent);
+ Type type = typeExpr.getType(context, stream);
Feature feature = null;
for (String each : features) {
if (StringUtils.equals(each, UIMAConstants.FEATURE_COVERED_TEXT)) {
@@ -102,9 +103,9 @@ public class SimpleFeatureExpression ext
return result;
}
- public TypeExpression getTypeExpr(RutaBlock parent) {
+ public TypeExpression getTypeExpr(MatchContext context, RutaStream stream) {
if (mr != null) {
- return mr.getTypeExpression(parent);
+ return mr.getTypeExpression(context, stream);
}
return typeExpr;
}
@@ -113,9 +114,9 @@ public class SimpleFeatureExpression ext
this.typeExpr = typeExpr;
}
- public List<String> getFeatureStringList(RutaBlock parent) {
+ public List<String> getFeatureStringList(MatchContext context, RutaStream stream) {
if (mr != null) {
- features = mr.getFeatureExpression(parent).getFeatureStringList(parent);
+ features = mr.getFeatureExpression(context, stream).getFeatureStringList(context, stream);
}
return features;
}
@@ -125,9 +126,9 @@ public class SimpleFeatureExpression ext
}
public Collection<AnnotationFS> getFeatureAnnotations(Collection<AnnotationFS> annotations,
- RutaStream stream, RutaBlock parent, boolean checkOnFeatureValue) {
+ RutaStream stream, MatchContext context, boolean checkOnFeatureValue) {
Collection<AnnotationFS> result = new TreeSet<AnnotationFS>(comparator);
- List<Feature> features = getFeatures(parent);
+ List<Feature> features = getFeatures(context, stream);
for (AnnotationFS eachBase : annotations) {
AnnotationFS afs = eachBase;
for (Feature feature : features) {
@@ -139,7 +140,7 @@ public class SimpleFeatureExpression ext
if (this instanceof FeatureMatchExpression) {
FeatureMatchExpression fme = (FeatureMatchExpression) this;
if (checkOnFeatureValue) {
- if (fme.checkFeatureValue(afs, feature, stream, parent)) {
+ if (fme.checkFeatureValue(afs, context, feature, stream)) {
result.add(afs);
}
} else {
@@ -178,4 +179,6 @@ public class SimpleFeatureExpression ext
return mr;
}
+
+
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/BooleanListVariableExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/BooleanListVariableExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/BooleanListVariableExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/BooleanListVariableExpression.java Fri Nov 6 17:17:42 2015
@@ -22,9 +22,11 @@ package org.apache.uima.ruta.expression.
import java.util.ArrayList;
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.rule.MatchContext;
public class BooleanListVariableExpression extends BooleanListExpression {
@@ -37,13 +39,14 @@ public class BooleanListVariableExpressi
@SuppressWarnings("unchecked")
@Override
- public List<Boolean> getList(RutaBlock parent, RutaStream stream) {
+ public List<Boolean> getList(MatchContext context, RutaStream stream) {
+ RutaBlock parent = context.getParent();
List<Object> list = parent.getEnvironment().getVariableValue(var, List.class);
List<Boolean> result = new ArrayList<Boolean>();
for (Object each : list) {
if (each instanceof IBooleanExpression) {
// TODO support arrays
- result.add(((IBooleanExpression) each).getBooleanValue(parent, null, stream));
+ result.add(((IBooleanExpression) each).getBooleanValue(context, stream));
} else if (each instanceof Boolean) {
result.add((Boolean) each);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/ListExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/ListExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/ListExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/ListExpression.java Fri Nov 6 17:17:42 2015
@@ -21,18 +21,17 @@ package org.apache.uima.ruta.expression.
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.string.AbstractStringExpression;
+import org.apache.uima.ruta.rule.MatchContext;
public abstract class ListExpression<T> extends AbstractStringExpression {
- public abstract List<T> getList(RutaBlock parent, RutaStream stream);
+ public abstract List<T> getList(MatchContext context, RutaStream stream);
@Override
- public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- return getList(parent, stream).toString();
+ public String getStringValue(MatchContext context, RutaStream stream) {
+ return getList(context, stream).toString();
}
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/NumberListVariableExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/NumberListVariableExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/NumberListVariableExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/NumberListVariableExpression.java Fri Nov 6 17:17:42 2015
@@ -22,9 +22,11 @@ package org.apache.uima.ruta.expression.
import java.util.ArrayList;
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.number.INumberExpression;
+import org.apache.uima.ruta.rule.MatchContext;
public class NumberListVariableExpression extends NumberListExpression {
@@ -37,13 +39,14 @@ public class NumberListVariableExpressio
@SuppressWarnings("unchecked")
@Override
- public List<Number> getList(RutaBlock parent, RutaStream stream) {
+ public List<Number> getList(MatchContext context, RutaStream stream) {
+ RutaBlock parent = context.getParent();
List<Object> list = parent.getEnvironment().getVariableValue(var, List.class);
List<Number> result = new ArrayList<Number>();
for (Object each : list) {
if (each instanceof INumberExpression) {
// TODO support arrays
- result.add(((INumberExpression) each).getDoubleValue(parent, null, stream));
+ result.add(((INumberExpression) each).getDoubleValue(context, stream));
} else if (each instanceof Number) {
result.add((Number) each);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleBooleanListExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleBooleanListExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleBooleanListExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleBooleanListExpression.java Fri Nov 6 17:17:42 2015
@@ -22,9 +22,9 @@ package org.apache.uima.ruta.expression.
import java.util.ArrayList;
import java.util.List;
-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.rule.MatchContext;
public class SimpleBooleanListExpression extends BooleanListExpression {
@@ -36,11 +36,11 @@ public class SimpleBooleanListExpression
}
@Override
- public List<Boolean> getList(RutaBlock parent, RutaStream stream) {
+ public List<Boolean> getList(MatchContext context, RutaStream stream) {
List<Boolean> result = new ArrayList<Boolean>();
for (IBooleanExpression each : list) {
// TODO support arrays
- result.add(each.getBooleanValue(parent, null, stream));
+ result.add(each.getBooleanValue(context, stream));
}
return result;
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleNumberListExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleNumberListExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleNumberListExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleNumberListExpression.java Fri Nov 6 17:17:42 2015
@@ -22,9 +22,9 @@ package org.apache.uima.ruta.expression.
import java.util.ArrayList;
import java.util.List;
-import org.apache.uima.ruta.RutaBlock;
import org.apache.uima.ruta.RutaStream;
import org.apache.uima.ruta.expression.number.INumberExpression;
+import org.apache.uima.ruta.rule.MatchContext;
public class SimpleNumberListExpression extends NumberListExpression {
@@ -36,11 +36,11 @@ public class SimpleNumberListExpression
}
@Override
- public List<Number> getList(RutaBlock parent, RutaStream stream) {
+ public List<Number> getList(MatchContext context, RutaStream stream) {
List<Number> result = new ArrayList<Number>();
for (INumberExpression each : list) {
// TODO support arrays
- result.add(each.getDoubleValue(parent, null, stream));
+ result.add(each.getDoubleValue(context, stream));
}
return result;
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleStringListExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleStringListExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleStringListExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleStringListExpression.java Fri Nov 6 17:17:42 2015
@@ -22,9 +22,9 @@ package org.apache.uima.ruta.expression.
import java.util.ArrayList;
import java.util.List;
-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;
public class SimpleStringListExpression extends StringListExpression {
@@ -36,11 +36,11 @@ public class SimpleStringListExpression
}
@Override
- public List<String> getList(RutaBlock parent, RutaStream stream) {
+ public List<String> getList(MatchContext context, RutaStream stream) {
List<String> result = new ArrayList<String>();
for (IStringExpression each : list) {
// TODO support arrays
- result.add(each.getStringValue(parent, null, stream));
+ result.add(each.getStringValue(context, stream));
}
return result;
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleTypeListExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleTypeListExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleTypeListExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/SimpleTypeListExpression.java Fri Nov 6 17:17:42 2015
@@ -23,9 +23,9 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.uima.cas.Type;
-import org.apache.uima.ruta.RutaBlock;
import org.apache.uima.ruta.RutaStream;
import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
public class SimpleTypeListExpression extends TypeListExpression {
@@ -37,10 +37,10 @@ public class SimpleTypeListExpression ex
}
@Override
- public List<Type> getList(RutaBlock parent, RutaStream stream) {
+ public List<Type> getList(MatchContext context, RutaStream stream) {
List<Type> result = new ArrayList<Type>();
for (TypeExpression each : list) {
- result.add(each.getType(parent));
+ result.add(each.getType(context, stream));
}
return result;
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/StringListVariableExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/StringListVariableExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/StringListVariableExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/StringListVariableExpression.java Fri Nov 6 17:17:42 2015
@@ -22,9 +22,11 @@ package org.apache.uima.ruta.expression.
import java.util.ArrayList;
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.string.AbstractStringExpression;
+import org.apache.uima.ruta.rule.MatchContext;
public class StringListVariableExpression extends StringListExpression {
@@ -37,13 +39,14 @@ public class StringListVariableExpressio
@SuppressWarnings("unchecked")
@Override
- public List<String> getList(RutaBlock parent, RutaStream stream) {
+ public List<String> getList(MatchContext context, RutaStream stream) {
+ RutaBlock parent = context.getParent();
List<Object> list = parent.getEnvironment().getVariableValue(var, List.class);
List<String> result = new ArrayList<String>();
for (Object each : list) {
if (each instanceof AbstractStringExpression) {
// TODO support arrays
- result.add(((AbstractStringExpression) each).getStringValue(parent, null, stream));
+ result.add(((AbstractStringExpression) each).getStringValue(context, stream));
} else if (each instanceof String) {
result.add((String) each);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/TypeListVariableExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/TypeListVariableExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/TypeListVariableExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/TypeListVariableExpression.java Fri Nov 6 17:17:42 2015
@@ -23,9 +23,11 @@ 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.ruta.RutaBlock;
import org.apache.uima.ruta.RutaStream;
import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
public class TypeListVariableExpression extends TypeListExpression {
@@ -38,12 +40,13 @@ public class TypeListVariableExpression
@SuppressWarnings("unchecked")
@Override
- public List<Type> getList(RutaBlock parent, RutaStream stream) {
+ public List<Type> getList(MatchContext context, RutaStream stream) {
+ RutaBlock parent = context.getParent();
List<Object> list = parent.getEnvironment().getVariableValue(var, List.class);
List<Type> result = new ArrayList<Type>();
for (Object each : list) {
if (each instanceof TypeExpression) {
- result.add(((TypeExpression) each).getType(parent));
+ result.add(((TypeExpression) each).getType(context, stream));
} else if (each instanceof Type) {
result.add((Type) each);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/UntypedListExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/UntypedListExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/UntypedListExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/list/UntypedListExpression.java Fri Nov 6 17:17:42 2015
@@ -22,13 +22,13 @@ package org.apache.uima.ruta.expression.
import java.util.ArrayList;
import java.util.List;
-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.bool.AbstractBooleanExpression;
import org.apache.uima.ruta.expression.number.AbstractNumberExpression;
import org.apache.uima.ruta.expression.string.AbstractStringExpression;
import org.apache.uima.ruta.expression.type.TypeExpression;
+import org.apache.uima.ruta.rule.MatchContext;
public class UntypedListExpression extends ListExpression<Object> {
@@ -40,20 +40,20 @@ public class UntypedListExpression exten
}
@Override
- public List<Object> getList(RutaBlock parent, RutaStream stream) {
+ public List<Object> getList(MatchContext context, RutaStream stream) {
List<Object> result = new ArrayList<Object>();
for (IRutaExpression each : list) {
// TODO support arrays
if (each instanceof AbstractBooleanExpression) {
- result.add(((AbstractBooleanExpression) each).getBooleanValue(parent, null, stream));
+ result.add(((AbstractBooleanExpression) each).getBooleanValue(context, stream));
} else if (each instanceof AbstractNumberExpression) {
- result.add(((AbstractNumberExpression) each).getDoubleValue(parent, null, stream));
+ result.add(((AbstractNumberExpression) each).getDoubleValue(context, stream));
} else if (each instanceof TypeExpression) {
- result.add(((TypeExpression) each).getType(parent));
+ result.add(((TypeExpression) each).getType(context, stream));
} else if (each instanceof ListExpression) {
- result.add(((ListExpression<?>) each).getList(parent, stream));
+ result.add(((ListExpression<?>) each).getList(context, stream));
} else if (each instanceof AbstractStringExpression) {
- result.add(((AbstractStringExpression) each).getStringValue(parent, null, stream));
+ result.add(((AbstractStringExpression) each).getStringValue(context, stream));
}
}
return result;
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/AbstractNumberExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/AbstractNumberExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/AbstractNumberExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/AbstractNumberExpression.java Fri Nov 6 17:17:42 2015
@@ -30,39 +30,6 @@ import org.apache.uima.ruta.rule.RuleMat
public abstract class AbstractNumberExpression extends AbstractStringExpression implements INumberExpression {
- public int getIntegerValue(RutaBlock parent, RuleMatch match, RuleElement element,
- RutaStream stream) {
- List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOfElement(element);
- // TODO: do we need to select the correct annotation?
- AnnotationFS annotation = null;
- if (!matchedAnnotationsOf.isEmpty()) {
- annotation = matchedAnnotationsOf.get(0);
- }
- return getIntegerValue(parent, annotation, stream);
- }
-
- public double getDoubleValue(RutaBlock parent, RuleMatch match, RuleElement element,
- RutaStream stream) {
- List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOfElement(element);
- // TODO: do we need to select the correct annotation?
- AnnotationFS annotation = null;
- if (!matchedAnnotationsOf.isEmpty()) {
- annotation = matchedAnnotationsOf.get(0);
- }
- return getDoubleValue(parent, annotation, stream);
- }
-
- public float getFloatValue(RutaBlock parent, RuleMatch match, RuleElement element,
- RutaStream stream) {
- List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOfElement(element);
- // TODO: do we need to select the correct annotation?
- AnnotationFS annotation = null;
- if (!matchedAnnotationsOf.isEmpty()) {
- annotation = matchedAnnotationsOf.get(0);
- }
- return getFloatValue(parent, annotation, stream);
- }
-
protected double calculate(double t1, double t2, String op) {
if ("+".equals(op)) {
return t1 + t2;
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/ComposedNumberExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/ComposedNumberExpression.java?rev=1712988&r1=1712987&r2=1712988&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/ComposedNumberExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/ComposedNumberExpression.java Fri Nov 6 17:17:42 2015
@@ -21,9 +21,8 @@ package org.apache.uima.ruta.expression.
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.rule.MatchContext;
public class ComposedNumberExpression extends AbstractNumberExpression {
@@ -37,44 +36,44 @@ public class ComposedNumberExpression ex
this.ops = ops;
}
- public double getDoubleValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
+ public double getDoubleValue(MatchContext context, RutaStream stream) {
INumberExpression numberExpression = getExpressions().get(0);
if (numberExpression == null) {
return 0;
}
- double result = numberExpression.getDoubleValue(parent, annotation, stream);
+ double result = numberExpression.getDoubleValue(context, stream);
for (int i = 0; i < getOperators().size(); i++) {
double second = 0;
if (getExpressions().size() > i + 1) {
- second = getExpressions().get(i + 1).getDoubleValue(parent, annotation, stream);
+ second = getExpressions().get(i + 1).getDoubleValue(context, stream);
}
result = calculate(result, second, getOperators().get(i));
}
return result;
}
- public float getFloatValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
+ public float getFloatValue(MatchContext context, RutaStream stream) {
INumberExpression numberExpression = getExpressions().get(0);
if (numberExpression == null) {
return 0;
}
- float result = numberExpression.getFloatValue(parent, annotation, stream);
+ float result = numberExpression.getFloatValue(context, stream);
for (int i = 0; i < getOperators().size(); i++) {
float second = 0;
if (getExpressions().size() > i + 1) {
- second = getExpressions().get(i + 1).getFloatValue(parent, annotation, stream);
+ second = getExpressions().get(i + 1).getFloatValue(context, stream);
}
result = calculate(result, second, getOperators().get(i));
}
return result;
}
- public int getIntegerValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- int result = getExpressions().get(0).getIntegerValue(parent, annotation, stream);
+ public int getIntegerValue(MatchContext context, RutaStream stream) {
+ int result = getExpressions().get(0).getIntegerValue(context, stream);
for (int i = 0; i < getOperators().size(); i++) {
int second = 0;
if (getExpressions().size() > i + 1) {
- second = getExpressions().get(i + 1).getIntegerValue(parent, annotation, stream);
+ second = getExpressions().get(i + 1).getIntegerValue(context, stream);
}
result = calculate(result, second, getOperators().get(i));
}
@@ -82,8 +81,8 @@ public class ComposedNumberExpression ex
}
@Override
- public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
- return "" + getDoubleValue(parent, annotation, stream);
+ public String getStringValue(MatchContext context, RutaStream stream) {
+ return "" + getDoubleValue(context, stream);
}
public List<INumberExpression> getExpressions() {