Merge branch 'main' into feature/UIMA-6337-Upgrade-Ruta-to-UIMA-3.2.0-and-uimaFIT-3.2.0
# Conflicts:
# ruta-parent/pom.xml
diff --git a/example-projects/ruta-ep-example-extensions/pom.xml b/example-projects/ruta-ep-example-extensions/pom.xml
index 5b581c1..524ee5a 100644
--- a/example-projects/ruta-ep-example-extensions/pom.xml
+++ b/example-projects/ruta-ep-example-extensions/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-ep-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../../ruta-ep-parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/example-projects/ruta-maven-example/pom.xml b/example-projects/ruta-maven-example/pom.xml
index 8d71cac..db0a8ea 100644
--- a/example-projects/ruta-maven-example/pom.xml
+++ b/example-projects/ruta-maven-example/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../../ruta-parent/pom.xml</relativePath>
</parent>
<url>${uimaWebsiteUrl}</url>
diff --git a/pom.xml b/pom.xml
index 2d79030..f726d84 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>ruta-parent/pom.xml</relativePath>
</parent>
diff --git a/ruta-basic-type/pom.xml b/ruta-basic-type/pom.xml
index 085d689..6a2b70c 100644
--- a/ruta-basic-type/pom.xml
+++ b/ruta-basic-type/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-parent/pom.xml</relativePath>
</parent>
diff --git a/ruta-core-ext/pom.xml b/ruta-core-ext/pom.xml
index ecdcb74..69f7d08 100644
--- a/ruta-core-ext/pom.xml
+++ b/ruta-core-ext/pom.xml
@@ -30,7 +30,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-parent/pom.xml</relativePath>
</parent>
diff --git a/ruta-core-ext/src/main/java/org/apache/uima/ruta/block/fst/Automaton.java b/ruta-core-ext/src/main/java/org/apache/uima/ruta/block/fst/Automaton.java
index 6d99ecb..6596cec 100644
--- a/ruta-core-ext/src/main/java/org/apache/uima/ruta/block/fst/Automaton.java
+++ b/ruta-core-ext/src/main/java/org/apache/uima/ruta/block/fst/Automaton.java
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.uima.ruta.block.fst;
import java.util.ArrayList;
@@ -168,7 +167,8 @@
* - the RutaBlock (is needed in called functions)
*/
private void doTransition(TransitionState startState, AnnotationFS anno, RuleElement ruleElement,
- LinkedList<RuleMatch> matches, RutaStream stream, InferenceCrowd crowd, RutaBlock parent) {
+ LinkedList<RuleMatch> matches, RutaStream stream, InferenceCrowd crowd,
+ RutaBlock parent) {
for (RuleElement element : startState.getPossibleTransitions()) {
RutaMatcher matcher = ((RutaRuleElement) element).getMatcher();
AbstractState targetState = startState.getTransition(element);
@@ -228,12 +228,12 @@
private void doMatch(AnnotationFS annotation, RuleMatch ruleMatch, RuleElement element,
ComposedRuleElementMatch containerMatch, RutaStream stream, InferenceCrowd crowd) {
RuleElementMatch result = new RuleElementMatch(element, containerMatch);
- List<EvaluatedCondition> evaluatedConditions = new ArrayList<EvaluatedCondition>(element
- .getConditions().size());
+ List<EvaluatedCondition> evaluatedConditions = new ArrayList<EvaluatedCondition>(
+ element.getConditions().size());
// boolean base = matcher.match(annotation, stream, getParent());
boolean base = true;
MatchContext context = new MatchContext(annotation, element, ruleMatch, true);
-
+
List<AnnotationFS> textsMatched = new ArrayList<AnnotationFS>(1);
if (annotation != null) {
textsMatched.add(annotation);
diff --git a/ruta-core/pom.xml b/ruta-core/pom.xml
index a1a83e7..dd3f558 100644
--- a/ruta-core/pom.xml
+++ b/ruta-core/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-parent/pom.xml</relativePath>
</parent>
diff --git a/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g b/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g
index ba761ab..4e5f7fb 100644
--- a/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g
+++ b/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g
@@ -2883,8 +2883,12 @@
:
e1 = annotationExpression
op = (EQUAL | NOTEQUAL)
- e2 = annotationExpression
+ (e2 = annotationExpression
{expr = expressionFactory.createBooleanAnnotationExpression(e1,op,e2);}
+ |
+ e3 = nullExpression
+ {expr = expressionFactory.createBooleanAnnotationExpression(e1,op,e3);}
+ )
;
booleanAnnotationListExpression returns [IBooleanExpression expr = null]
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/RutaBasicUtils.java b/ruta-core/src/main/java/org/apache/uima/ruta/RutaBasicUtils.java
index f371d49..473f75d 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/RutaBasicUtils.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/RutaBasicUtils.java
@@ -62,6 +62,11 @@
CAS cas = annotation.getCAS();
TypeSystem typeSystem = cas.getTypeSystem();
Type basicType = typeSystem.getType(RutaBasic.class.getName());
+
+ if (basicType == null) {
+ return false;
+ }
+
Type type = annotation.getType();
if (typeSystem.subsumes(basicType, type)) {
@@ -107,6 +112,11 @@
CAS cas = annotation.getCAS();
TypeSystem typeSystem = cas.getTypeSystem();
Type basicType = typeSystem.getType(RutaBasic.class.getName());
+
+ if (basicType == null) {
+ return false;
+ }
+
Type type = annotation.getType();
if (typeSystem.subsumes(basicType, type)) {
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/RutaEnvironment.java b/ruta-core/src/main/java/org/apache/uima/ruta/RutaEnvironment.java
index fa70516..6808395 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/RutaEnvironment.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/RutaEnvironment.java
@@ -33,6 +33,7 @@
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
+import java.util.regex.Pattern;
import org.antlr.runtime.CommonToken;
import org.apache.commons.lang3.StringUtils;
@@ -184,6 +185,8 @@
private RutaVerbalizer verbalizer = new RutaVerbalizer();
+ private Pattern typeIgnorePattern;
+
public RutaEnvironment(RutaBlock owner) {
super();
this.owner = owner;
@@ -475,9 +478,22 @@
return type;
}
- public void addType(String string, Type type) {
- importType(type.getName(), string);
- types.put(type.getName(), type);
+ public void addType(String shortName, Type type) {
+ String name = type.getName();
+
+ if (ignoreType(name)) {
+ return;
+ }
+
+ importType(name, shortName);
+ types.put(name, type);
+ }
+
+ private boolean ignoreType(String name) {
+ if (typeIgnorePattern == null) {
+ return false;
+ }
+ return typeIgnorePattern.matcher(name).matches();
}
public void addType(Type type) {
@@ -1230,4 +1246,8 @@
}
}
}
+
+ public void setTypeIgnorePattern(Pattern pattern) {
+ typeIgnorePattern = pattern;
+ }
}
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/action/AddAction.java b/ruta-core/src/main/java/org/apache/uima/ruta/action/AddAction.java
index 78a9c1a..ae455c2 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/action/AddAction.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/action/AddAction.java
@@ -73,13 +73,15 @@
list.add(((INumberExpression) each).getIntegerValue(context, stream));
} else if (vgtype.equals(Double.class) && each instanceof INumberExpression) {
list.add(((INumberExpression) each).getDoubleValue(context, stream));
+ } else if (vgtype.equals(Float.class) && each instanceof INumberExpression) {
+ list.add(((INumberExpression) each).getFloatValue(context, stream));
} else if (vgtype.equals(Type.class) && each instanceof ITypeExpression) {
list.add(((ITypeExpression) each).getType(context, stream));
} else if (vgtype.equals(String.class) && each instanceof IStringExpression) {
list.add(((IStringExpression) each).getStringValue(context, stream));
} else if (vgtype.equals(AnnotationFS.class) && each instanceof IAnnotationExpression) {
AnnotationFS annotation = ((IAnnotationExpression) each).getAnnotation(context, stream);
- if(annotation != null) {
+ if (annotation != null) {
list.add(annotation);
}
} else if (each instanceof ListExpression) {
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveAction.java b/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveAction.java
index 4d6dfe6..d70c743 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveAction.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveAction.java
@@ -92,7 +92,11 @@
}
private Object getValue(Object obj, Class<?> vgtype, MatchContext context, RutaStream stream) {
- if (obj instanceof INumberExpression) {
+ if (vgtype.equals(Integer.class) && obj instanceof INumberExpression) {
+ return ((INumberExpression) obj).getIntegerValue(context, stream);
+ } else if (vgtype.equals(Float.class) && obj instanceof INumberExpression) {
+ return ((INumberExpression) obj).getFloatValue(context, stream);
+ } else if (obj instanceof INumberExpression) {
return ((INumberExpression) obj).getDoubleValue(context, stream);
} else if (obj instanceof IBooleanExpression) {
return ((IBooleanExpression) obj).getBooleanValue(context, stream);
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/engine/Ruta.java b/ruta-core/src/main/java/org/apache/uima/ruta/engine/Ruta.java
index f934c95..cefd577 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/engine/Ruta.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/engine/Ruta.java
@@ -42,7 +42,7 @@
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData;
import org.apache.uima.cas.CAS;
-import org.apache.uima.cas.impl.FeatureStructureImpl;
+import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.fit.factory.AnalysisEngineFactory;
import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;
@@ -58,6 +58,7 @@
import org.apache.uima.ruta.type.DebugMatchedRuleMatch;
import org.apache.uima.ruta.type.DebugRuleApply;
import org.apache.uima.ruta.type.DebugRuleMatch;
+import org.apache.uima.ruta.type.DebugScriptApply;
import org.apache.uima.util.CasCreationUtils;
import org.apache.uima.util.FileUtils;
import org.apache.uima.util.InvalidXMLException;
@@ -145,7 +146,7 @@
int result = 0;
if (annotation instanceof DebugBlockApply) {
DebugBlockApply dba = (DebugBlockApply) annotation;
- FSArray innerApply = dba.getInnerApply();
+ FSArray<DebugScriptApply> innerApply = dba.getInnerApply();
for (int i = 0; i < innerApply.size(); i++) {
Annotation each = (Annotation) innerApply.get(i);
result += countRuleApplies(each);
@@ -160,14 +161,14 @@
private static void collectRuleMatches(Annotation annotation, List<Annotation> result) {
if (annotation instanceof DebugBlockApply) {
DebugBlockApply dba = (DebugBlockApply) annotation;
- FSArray innerApply = dba.getInnerApply();
+ FSArray<DebugScriptApply> innerApply = dba.getInnerApply();
for (int i = 0; i < innerApply.size(); i++) {
Annotation each = (Annotation) innerApply.get(i);
collectRuleMatches(each, result);
}
} else if (annotation instanceof DebugRuleApply) {
DebugRuleApply dra = (DebugRuleApply) annotation;
- FSArray rules = dra.getRules();
+ FSArray<DebugRuleMatch> rules = dra.getRules();
for (int i = 0; i < rules.size(); i++) {
Annotation each = (Annotation) rules.get(i);
collectRuleMatches(each, result);
@@ -214,11 +215,11 @@
return sb.toString();
}
- public static String inject(String script, FeatureStructureImpl... annotations) {
+ public static String inject(String script, FeatureStructure... annotations) {
return inject(script, "$", getAddresses(annotations));
}
- private static int[] getAddresses(FeatureStructureImpl[] annotations) {
+ private static int[] getAddresses(FeatureStructure[] annotations) {
int[] result = new int[annotations.length];
for (int i = 0; i < annotations.length; i++) {
result[i] = annotations[i].getAddress();
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaEngine.java b/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaEngine.java
index d2a98fc..a4cc901 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaEngine.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaEngine.java
@@ -32,6 +32,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.regex.Pattern;
import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.ANTLRStringStream;
@@ -343,6 +344,15 @@
private Boolean debugWithMatches;
/**
+ * This parameter specifies whether all debug annotation should be added to the indexes. By
+ * default this parameter is deactivated and only the root script apply is added.
+ */
+ public static final String PARAM_DEBUG_ADD_TO_INDEXES = "debugAddToIndexes";
+
+ @ConfigurationParameter(name = PARAM_DEBUG_ADD_TO_INDEXES, mandatory = false, defaultValue = "false")
+ private Boolean debugAddToIndexes;
+
+ /**
* This parameter specifies a list of rule-ids that enumerate the rule for which debug information
* should be created. No specific ids are given by default.
*/
@@ -389,6 +399,16 @@
private Boolean strictImports = false;
/**
+ * An optional pattern (regular expression) which defined types that should be ignored. These
+ * types will not be resolved even if strictImports is set to false. This parameter can be used to
+ * ignore complete namespaces of type that could contain ambiguous short names.
+ */
+ public static final String PARAM_TYPE_IGNORE_PATTERN = "typeIgnorePattern";
+
+ @ConfigurationParameter(name = PARAM_TYPE_IGNORE_PATTERN, mandatory = false)
+ private Pattern typeIgnorePattern;
+
+ /**
* If this parameter is set to true, then whitespaces are removed when dictionaries are loaded.
*/
public static final String PARAM_DICT_REMOVE_WS = "dictRemoveWS";
@@ -792,6 +812,7 @@
initialized.add(name);
}
}
+ mainRootBlock.getEnvironment().setTypeIgnorePattern(typeIgnorePattern);
mainRootBlock.getEnvironment().initializeTypes(cas, strictImports);
}
@@ -841,7 +862,7 @@
private InferenceCrowd initializeCrowd() {
List<RutaInferenceVisitor> visitors = new ArrayList<RutaInferenceVisitor>();
if (debug) {
- visitors.add(new DebugInfoCollectorVisitor(debug, debugWithMatches,
+ visitors.add(new DebugInfoCollectorVisitor(debug, debugWithMatches, debugAddToIndexes,
Arrays.asList(debugOnlyFor), verbalizer));
}
if (profile) {
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/FeatureMatchExpression.java b/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/FeatureMatchExpression.java
index afc64c5..94a66e7 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/FeatureMatchExpression.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/FeatureMatchExpression.java
@@ -159,7 +159,7 @@
} else if (!feature.getRange().isPrimitive()
&& typeSystem.subsumes(typeSystem.getType(CAS.TYPE_NAME_FS_ARRAY), featureRangeType)
&& getArg() instanceof IAnnotationListExpression) {
- ArrayFS fsArray = (ArrayFS) featureValue;
+ ArrayFS<?> fsArray = (ArrayFS<?>) featureValue;
IAnnotationListExpression ale = (IAnnotationListExpression) getArg();
List<AnnotationFS> annotationList = ale.getAnnotationList(context, stream);
return compare(Arrays.asList(fsArray.toArray()), annotationList);
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/SimpleFeatureExpression.java b/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/SimpleFeatureExpression.java
index 94119ac..f14e7e6 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/SimpleFeatureExpression.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/expression/feature/SimpleFeatureExpression.java
@@ -282,7 +282,7 @@
this.collectFeatureStructures(next, tail, checkOnFeatureValue, collectOnlyAnnotations,
lastValidFeatureStructure, result, stream, context);
} else if (value instanceof FSArray && index >= 0) {
- FSArray array = (FSArray) value;
+ FSArray<?> array = (FSArray<?>) value;
if (index < array.size()) {
FeatureStructure fs = array.get(index);
if (fs instanceof AnnotationFS) {
@@ -292,7 +292,7 @@
}
}
} else if (value instanceof FSArray) {
- FSArray array = (FSArray) value;
+ FSArray<?> array = (FSArray<?>) value;
for (int i = 0; i < array.size(); i++) {
FeatureStructure fs = array.get(i);
this.collectFeatureStructures(fs, tail, checkOnFeatureValue, collectOnlyAnnotations,
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/resource/MultiTreeWordList.java b/ruta-core/src/main/java/org/apache/uima/ruta/resource/MultiTreeWordList.java
index c382c38..e2db610 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/resource/MultiTreeWordList.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/resource/MultiTreeWordList.java
@@ -38,7 +38,6 @@
import org.apache.commons.io.IOUtils;
import org.apache.uima.cas.CAS;
-import org.apache.uima.cas.FSIterator;
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.TypeSystem;
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/resource/TreeWordList.java b/ruta-core/src/main/java/org/apache/uima/ruta/resource/TreeWordList.java
index 4c1ca1e..297daec 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/resource/TreeWordList.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/resource/TreeWordList.java
@@ -37,7 +37,6 @@
import java.util.zip.ZipOutputStream;
import org.apache.commons.text.StringEscapeUtils;
-import org.apache.uima.cas.FSIterator;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.internal.util.XMLUtils;
import org.apache.uima.jcas.tcas.Annotation;
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java b/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java
index b5634a9..e25038b 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java
@@ -420,6 +420,10 @@
RuleElementContainer container = getContainer();
doMatch(after, annotation, ruleMatch, containerMatch, isStartAnchor(), stream, crowd);
if (equals(entryPoint) && ruleApply == null) {
+ if (failed) {
+ // inform caller about the failed state using the matched info
+ ruleMatch.setMatched(false);
+ }
result.add(ruleMatch);
} else if (container == null) {
result = fallback(after, failed, annotation, ruleMatch, ruleApply, containerMatch,
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaAnnotationTypeMatcher.java b/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaAnnotationTypeMatcher.java
index 98780c7..e1ac291 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaAnnotationTypeMatcher.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaAnnotationTypeMatcher.java
@@ -26,7 +26,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.uima.cas.CAS;
@@ -61,11 +60,11 @@
// avoid null lists here
return result != null ? result : emptyList();
}
-
+
if (expression.getAnnotationExpression() != null) {
return asList(expression.getAnnotation(context, stream));
}
-
+
// TODO defer to getter of expression?
List<Type> types;
if (expression.getTypeListExpression() != null) {
@@ -73,7 +72,7 @@
} else {
types = asList(getType(context.getParent(), stream));
}
-
+
Collection<AnnotationFS> result = new ArrayList<>();
for (Type type : types) {
if (type == null) {
@@ -83,14 +82,13 @@
Type overallDAType = stream.getCas().getDocumentAnnotation().getType();
String name = type.getName();
if (CAS.TYPE_NAME_DOCUMENT_ANNOTATION.equals(name)
- || "org.apache.uima.ruta.type.Document".equals(name)
- || overallDAType.equals(type)) {
+ || "org.apache.uima.ruta.type.Document".equals(name) || overallDAType.equals(type)) {
// TODO what about dynamic windowing?
result.add(stream.getDocumentAnnotation());
} else {
result.addAll(stream.getAnnotations(type));
}
-
+
// TODO: Throwing away the result so far in this for loop seems odd
if (expression.getFeatureExpression() != null) {
@SuppressWarnings("unchecked")
@@ -99,7 +97,7 @@
result = r;
}
}
-
+
return result;
}
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/utils/UIMAUtils.java b/ruta-core/src/main/java/org/apache/uima/ruta/utils/UIMAUtils.java
index 560a88a..cac0a9a 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/utils/UIMAUtils.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/utils/UIMAUtils.java
@@ -31,8 +31,9 @@
public class UIMAUtils {
- public static FSArray toFSArray(JCas jCas, List<? extends FeatureStructure> fsList) {
- FSArray fsArray = new FSArray(jCas, fsList.size());
+ public static FSArray<? extends FeatureStructure> toFSArray(JCas jCas,
+ List<? extends FeatureStructure> fsList) {
+ FSArray<FeatureStructure> fsArray = new FSArray<FeatureStructure>(jCas, fsList.size());
fsArray.copyFromArray(fsList.toArray(new FeatureStructure[fsList.size()]), 0, 0, fsList.size());
return fsArray;
}
@@ -55,7 +56,8 @@
return uimaSArray;
}
- public static <T extends FeatureStructure> List<T> toList(FSArray fsArray, Class<T> cls) {
+ public static <T extends FeatureStructure> List<T> toList(FSArray<FeatureStructure> fsArray,
+ Class<T> cls) {
List<T> list = new ArrayList<T>();
if (fsArray == null) {
return list;
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/visitor/DebugInfoCollectorVisitor.java b/ruta-core/src/main/java/org/apache/uima/ruta/visitor/DebugInfoCollectorVisitor.java
index 98ee21e..b32a20b 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/visitor/DebugInfoCollectorVisitor.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/visitor/DebugInfoCollectorVisitor.java
@@ -19,7 +19,6 @@
package org.apache.uima.ruta.visitor;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -50,17 +49,20 @@
private boolean withMatches;
+ private boolean addToIndexes;
+
private ScriptApply rootApply;
private Map<RutaStatement, Stack<ScriptApply>> applies;
private Stack<RutaElement> callStack;
- public DebugInfoCollectorVisitor(boolean createDebugInfo, boolean withMatches, List<String> ids,
- RutaVerbalizer verbalizer) {
+ public DebugInfoCollectorVisitor(boolean createDebugInfo, boolean withMatches,
+ boolean addToIndexes, List<String> ids, RutaVerbalizer verbalizer) {
super();
this.createDebugInfo = createDebugInfo;
this.withMatches = withMatches;
+ this.addToIndexes = addToIndexes;
this.ids = ids;
debugFactory = new DebugInfoFactory(verbalizer);
@@ -68,10 +70,9 @@
callStack = new Stack<RutaElement>();
}
- public DebugInfoCollectorVisitor(boolean createDebugInfo) {
- super();
- this.createDebugInfo = createDebugInfo;
- this.ids = new ArrayList<String>();
+ public DebugInfoCollectorVisitor(boolean createDebugInfo, boolean withMatches, List<String> ids,
+ RutaVerbalizer verbalizer) {
+ this(createDebugInfo, withMatches, false, ids, verbalizer);
}
public boolean isCreateDebugInfo() {
@@ -167,7 +168,7 @@
Map<RutaElement, Long> timeInfo = getTimeInfo(visitors);
DebugScriptApply debugScriptApply = debugFactory.createDebugScriptApply(rootApply, stream,
- false, withMatches, timeInfo);
+ addToIndexes, withMatches, timeInfo);
debugScriptApply.setTimestamp(System.currentTimeMillis());
debugScriptApply.addToIndexes();
}
diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/visitor/DebugInfoFactory.java b/ruta-core/src/main/java/org/apache/uima/ruta/visitor/DebugInfoFactory.java
index 65bf634..b71cf29 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/visitor/DebugInfoFactory.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/visitor/DebugInfoFactory.java
@@ -56,7 +56,6 @@
import org.apache.uima.ruta.type.DebugRuleElementMatches;
import org.apache.uima.ruta.type.DebugRuleMatch;
import org.apache.uima.ruta.type.DebugScriptApply;
-import org.apache.uima.ruta.utils.UIMAUtils;
import org.apache.uima.ruta.verbalize.RutaVerbalizer;
public class DebugInfoFactory {
@@ -115,18 +114,18 @@
ruleMatches.add(createDebugRuleMatch(ruleMatch, stream, addToIndex, withMatches, timeInfo));
dummyBlockApply.setApplied(1);
dummyBlockApply.setTried(1);
- dummyBlockApply.setRules(UIMAUtils.toFSArray(cas, ruleMatches));
+ dummyBlockApply.setRules(FSCollectionFactory.createFSArray(cas, ruleMatches));
List<DebugScriptApply> innerInnerApply = new ArrayList<DebugScriptApply>();
for (ScriptApply each : list) {
DebugScriptApply eachInnerInner = createDebugScriptApply(each, stream, addToIndex,
withMatches, timeInfo);
innerInnerApply.add(eachInnerInner);
}
- dummyBlockApply.setInnerApply(UIMAUtils.toFSArray(cas, innerInnerApply));
+ dummyBlockApply.setInnerApply(FSCollectionFactory.createFSArray(cas, innerInnerApply));
innerApply.add(dummyBlockApply);
counter++;
}
- dba.setInnerApply(UIMAUtils.toFSArray(cas, innerApply));
+ dba.setInnerApply(FSCollectionFactory.createFSArray(cas, innerApply));
dba.setElement(verbalize);
DebugRuleApply ruleApply = createDebugRuleApply(blockApply.getRuleApply(), stream, addToIndex,
withMatches, timeInfo);
@@ -147,7 +146,7 @@
for (ScriptApply each : blockApply.getInnerApplies()) {
innerApply.add(createDebugScriptApply(each, stream, addToIndex, withMatches, timeInfo));
}
- dba.setInnerApply(UIMAUtils.toFSArray(cas, innerApply));
+ dba.setInnerApply(FSCollectionFactory.createFSArray(cas, innerApply));
dba.setElement(verbalize);
DebugRuleApply ruleApply = createDebugRuleApply(blockApply.getRuleApply(), stream, addToIndex,
withMatches, timeInfo);
@@ -187,7 +186,7 @@
if (begin >= end) {
begin = end;
}
- dra.setRules(UIMAUtils.toFSArray(cas, ruleMatches));
+ dra.setRules(FSCollectionFactory.createFSArray(cas, ruleMatches));
RutaElement element = ruleApply.getElement();
String namespace = "";
if (element instanceof RutaStatement) {
@@ -231,7 +230,7 @@
for (ScriptApply rem : ((RuleMatch) match).getDelegateApply().values()) {
delegates.add(createDebugScriptApply(rem, stream, addToIndex, withMatches, timeInfo));
}
- drm.setDelegates(UIMAUtils.toFSArray(cas, delegates));
+ drm.setDelegates(FSCollectionFactory.createFSArray(cas, delegates));
// }
} else if (match instanceof RegExpRuleMatch) {
RegExpRuleMatch rerm = (RegExpRuleMatch) match;
@@ -264,14 +263,14 @@
remList.add(drem);
}
}
- drems.setMatches(UIMAUtils.toFSArray(cas, remList));
+ drems.setMatches(FSCollectionFactory.createFSArray(cas, remList));
if (addToIndex) {
drems.addToIndexes();
}
ruleElementMatches.add(drems);
}
- drm.setElements(UIMAUtils.toFSArray(cas, ruleElementMatches));
+ drm.setElements(FSCollectionFactory.createFSArray(cas, ruleElementMatches));
}
if (timeInfo != null) {
long time = timeInfo.get(match.getRule());
@@ -302,7 +301,7 @@
createDebugRuleElementMatches(re, rems, stream, addToIndex, withMatches, timeInfo));
}
- drm.setElements(UIMAUtils.toFSArray(stream.getJCas(), ruleElementMatches));
+ drm.setElements(FSCollectionFactory.createFSArray(stream.getJCas(), ruleElementMatches));
}
private void setInnerMatches(RutaStream stream, boolean addToIndex, boolean withMatches,
@@ -317,7 +316,7 @@
ruleElementMatches.add(
createDebugRuleElementMatches(re, rems, stream, addToIndex, withMatches, timeInfo));
}
- drm.setElements(UIMAUtils.toFSArray(stream.getJCas(), ruleElementMatches));
+ drm.setElements(FSCollectionFactory.createFSArray(stream.getJCas(), ruleElementMatches));
}
public DebugRuleElementMatches createDebugRuleElementMatches(RuleElement re,
@@ -336,8 +335,8 @@
} else {
rem = createDebugRuleElementMatch(each, stream, addToIndex);
}
- FSArray inlinedConditionBlocks = createInlinedBlocks(each.getInlinedConditionRules(),
- stream, true, addToIndex, withMatches, timeInfo);
+ FSArray<DebugInlinedBlock> inlinedConditionBlocks = createInlinedBlocks(
+ each.getInlinedConditionRules(), stream, true, addToIndex, withMatches, timeInfo);
rem.setInlinedConditionBlocks(inlinedConditionBlocks);
if (rem != null) {
remList.add(rem);
@@ -347,10 +346,10 @@
if (rems != null && !rems.isEmpty()) {
drems.setRuleAnchor(rems.get(0).isRuleAnchor());
}
- drems.setMatches(UIMAUtils.toFSArray(cas, remList));
+ drems.setMatches(FSCollectionFactory.createFSArray(cas, remList));
- FSArray inlinedActionBlocks = createInlinedActionBlocks(rems, stream, addToIndex, withMatches,
- timeInfo);
+ FSArray<DebugInlinedBlock> inlinedActionBlocks = createInlinedActionBlocks(rems, stream,
+ addToIndex, withMatches, timeInfo);
drems.setInlinedActionBlocks(inlinedActionBlocks);
if (addToIndex)
@@ -358,8 +357,8 @@
return drems;
}
- private FSArray createInlinedBlocks(List<List<ScriptApply>> blocks, RutaStream stream,
- boolean asCondition, boolean addToIndex, boolean withMatches,
+ private FSArray<DebugInlinedBlock> createInlinedBlocks(List<List<ScriptApply>> blocks,
+ RutaStream stream, boolean asCondition, boolean addToIndex, boolean withMatches,
Map<RutaElement, Long> timeInfo) {
JCas jcas = stream.getJCas();
if (blocks == null || blocks.isEmpty()) {
@@ -394,8 +393,9 @@
return FSCollectionFactory.createFSArray(jcas, blockList);
}
- private FSArray createInlinedActionBlocks(List<RuleElementMatch> rems, RutaStream stream,
- boolean addToIndex, boolean withMatches, Map<RutaElement, Long> timeInfo) {
+ private FSArray<DebugInlinedBlock> createInlinedActionBlocks(List<RuleElementMatch> rems,
+ RutaStream stream, boolean addToIndex, boolean withMatches,
+ Map<RutaElement, Long> timeInfo) {
if (rems == null || rems.isEmpty()) {
return null;
}
@@ -467,8 +467,8 @@
return drem;
}
- private FSArray createEvaluatedConditions(RuleElementMatch rem, RutaStream stream,
- boolean addToIndex) {
+ private FSArray<DebugEvaluatedCondition> createEvaluatedConditions(RuleElementMatch rem,
+ RutaStream stream, boolean addToIndex) {
JCas cas = stream.getJCas();
List<DebugEvaluatedCondition> ecs = new ArrayList<DebugEvaluatedCondition>();
if (rem.getConditions() != null) {
@@ -480,12 +480,12 @@
ecs.add(ec);
}
}
- FSArray result = UIMAUtils.toFSArray(cas, ecs);
+ FSArray<DebugEvaluatedCondition> result = FSCollectionFactory.createFSArray(cas, ecs);
return result;
}
- private FSArray createEvaluatedConditions(EvaluatedCondition eval, RutaStream stream,
- boolean addToIndex) {
+ private FSArray<DebugEvaluatedCondition> createEvaluatedConditions(EvaluatedCondition eval,
+ RutaStream stream, boolean addToIndex) {
JCas cas = stream.getJCas();
List<DebugEvaluatedCondition> ecs = new ArrayList<DebugEvaluatedCondition>();
for (EvaluatedCondition each : eval.getConditions()) {
@@ -495,7 +495,7 @@
ec.setConditions(createEvaluatedConditions(each, stream, addToIndex));
ecs.add(ec);
}
- FSArray result = UIMAUtils.toFSArray(cas, ecs);
+ FSArray<DebugEvaluatedCondition> result = FSCollectionFactory.createFSArray(cas, ecs);
return result;
}
diff --git a/ruta-core/src/main/resources/org/apache/uima/ruta/engine/BasicEngine.xml b/ruta-core/src/main/resources/org/apache/uima/ruta/engine/BasicEngine.xml
index 487c3b4..b789b81 100644
--- a/ruta-core/src/main/resources/org/apache/uima/ruta/engine/BasicEngine.xml
+++ b/ruta-core/src/main/resources/org/apache/uima/ruta/engine/BasicEngine.xml
@@ -58,6 +58,12 @@
<mandatory>false</mandatory>
</configurationParameter>
<configurationParameter>
+ <name>debugAddToIndexes</name>
+ <type>Boolean</type>
+ <multiValued>false</multiValued>
+ <mandatory>false</mandatory>
+ </configurationParameter>
+ <configurationParameter>
<name>statistics</name>
<type>Boolean</type>
<multiValued>false</multiValued>
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/TypeIgnorePatternTest.java b/ruta-core/src/test/java/org/apache/uima/ruta/TypeIgnorePatternTest.java
new file mode 100644
index 0000000..fcc0e04
--- /dev/null
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/TypeIgnorePatternTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.ruta;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.ruta.engine.Ruta;
+import org.apache.uima.ruta.engine.RutaEngine;
+import org.apache.uima.ruta.engine.RutaTestUtils;
+import org.junit.Test;
+
+public class TypeIgnorePatternTest {
+
+ @Test
+ public void test() throws Exception {
+ Map<String, String> complexTypes = new HashMap<>();
+ complexTypes.put("uima.ruta.Type1", CAS.TYPE_NAME_ANNOTATION);
+ complexTypes.put("bad.package.Type1", CAS.TYPE_NAME_ANNOTATION);
+
+ CAS cas = RutaTestUtils.getCAS("text", complexTypes, null);
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put(RutaEngine.PARAM_TYPE_IGNORE_PATTERN, ".*bad.*");
+ Ruta.apply(cas, "W{->Type1};Type1{->T1};", params);
+
+ RutaTestUtils.assertAnnotationsEquals(cas, 1, 1, "text");
+ }
+
+}
\ No newline at end of file
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/action/AddTest.java b/ruta-core/src/test/java/org/apache/uima/ruta/action/AddTest.java
index faa55c6..a668e9b 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/action/AddTest.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/action/AddTest.java
@@ -47,6 +47,23 @@
}
@Test
+ public void testFloat() throws Exception {
+ String document = "Some text.";
+ String script = "";
+ script += "FLOATLIST fs;";
+ script += "CW{-> ADD(fs,3)};";
+ script += "Document{SIZE(fs,1,1)->T1};";
+ script += "SW{-> ADD(fs,4)};";
+ script += "Document{SIZE(fs,2,2)->T2};";
+
+ CAS cas = RutaTestUtils.getCAS(document);
+ Ruta.apply(cas, script);
+
+ RutaTestUtils.assertAnnotationsEquals(cas, 1, 1, "Some text.");
+ RutaTestUtils.assertAnnotationsEquals(cas, 2, 1, "Some text.");
+ }
+
+ @Test
public void testVariable() throws Exception {
String document = "This is a test.";
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/engine/DummySeeder.java b/ruta-core/src/test/java/org/apache/uima/ruta/engine/DummySeeder.java
index b403f03..8712425 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/engine/DummySeeder.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/engine/DummySeeder.java
@@ -1,37 +1,36 @@
-/*
- * 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.ruta.engine;
-
-import org.apache.uima.cas.CAS;
-import org.apache.uima.cas.Type;
-import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.ruta.seed.RutaAnnotationSeeder;
-import org.apache.uima.ruta.seed.TextSeeder;
-
-public class DummySeeder implements RutaAnnotationSeeder{
-
- @Override
- public Type seed(String text, CAS cas) {
- Type type = cas.getTypeSystem().getType(TextSeeder.seedType);
- AnnotationFS annotation = cas.createAnnotation(type, 0, text.length());
- cas.addFsToIndexes(annotation);
- return type;
- }
-
-}
+/*
+ * 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.ruta.engine;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.ruta.seed.RutaAnnotationSeeder;
+import org.apache.uima.ruta.seed.TextSeeder;
+
+public class DummySeeder implements RutaAnnotationSeeder {
+
+ @Override
+ public Type seed(String text, CAS cas) {
+ Type type = cas.getTypeSystem().getType(TextSeeder.seedType);
+ AnnotationFS annotation = cas.createAnnotation(type, 0, text.length());
+ cas.addFsToIndexes(annotation);
+ return type;
+ }
+}
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/engine/RulesParamTest.java b/ruta-core/src/test/java/org/apache/uima/ruta/engine/RulesParamTest.java
index aa4ce4d..79e2d79 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/engine/RulesParamTest.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/engine/RulesParamTest.java
@@ -49,16 +49,10 @@
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
ae.setConfigParameterValue(RutaEngine.PARAM_RULES, script);
ae.reconfigure();
- CAS cas = null;
- try {
- cas = RutaTestUtils.getCAS(document);
- ae.process(cas);
- } catch (Exception e) {
- e.printStackTrace();
- }
+
+ CAS cas = RutaTestUtils.getCAS(document);
+ ae.process(cas);
RutaTestUtils.assertAnnotationsEquals(cas, 1, 1, "text");
-
- cas.release();
}
}
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/engine/RutaTest.java b/ruta-core/src/test/java/org/apache/uima/ruta/engine/RutaTest.java
index 506c706..6af0aad 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/engine/RutaTest.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/engine/RutaTest.java
@@ -30,7 +30,6 @@
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.FSIterator;
import org.apache.uima.cas.Type;
-import org.apache.uima.cas.impl.AnnotationImpl;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.cas.text.AnnotationIndex;
import org.apache.uima.jcas.JCas;
@@ -153,8 +152,7 @@
public void testSelectWithInjection() throws Exception {
String document = "Some text.";
CAS cas = RutaTestUtils.getCAS(document);
- AnnotationImpl t1 = (AnnotationImpl) cas.createAnnotation(RutaTestUtils.getTestType(cas, 1), 5,
- 9);
+ Annotation t1 = (Annotation) cas.createAnnotation(RutaTestUtils.getTestType(cas, 1), 5, 9);
cas.addFsToIndexes(t1);
JCas jcas = cas.getJCas();
List<Annotation> select1 = Ruta.select(jcas, Ruta.inject("W $;", t1));
@@ -177,8 +175,7 @@
public void testMatchesWithInjection() throws Exception {
String document = "Some text.";
CAS cas = RutaTestUtils.getCAS(document);
- AnnotationImpl t1 = (AnnotationImpl) cas.createAnnotation(RutaTestUtils.getTestType(cas, 1), 5,
- 9);
+ Annotation t1 = (Annotation) cas.createAnnotation(RutaTestUtils.getTestType(cas, 1), 5, 9);
cas.addFsToIndexes(t1);
JCas jcas = cas.getJCas();
Assert.assertTrue(Ruta.matches(jcas, Ruta.inject("W $;", t1)));
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/engine/TestRutaInferenceVisitor.java b/ruta-core/src/test/java/org/apache/uima/ruta/engine/TestRutaInferenceVisitor.java
index 5cf4ca5..4988241 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/engine/TestRutaInferenceVisitor.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/engine/TestRutaInferenceVisitor.java
@@ -40,6 +40,7 @@
public void endVisit(RutaElement element, ScriptApply result) {
throw new NotImplementedException("Not supported.");
}
+
@Override
public void finished(RutaStream stream, List<RutaInferenceVisitor> visitors) {
throw new NotImplementedException("Not supported.");
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationAddressExpressionTest.java b/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationAddressExpressionTest.java
index 634580e..89a02ff 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationAddressExpressionTest.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationAddressExpressionTest.java
@@ -31,9 +31,9 @@
import org.apache.uima.cas.FSIterator;
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.Type;
-import org.apache.uima.cas.impl.AnnotationImpl;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.jcas.tcas.Annotation;
import org.apache.uima.ruta.engine.Ruta;
import org.apache.uima.ruta.engine.RutaTestUtils;
import org.apache.uima.ruta.engine.RutaTestUtils.TestFeature;
@@ -55,8 +55,8 @@
AnnotationFS a1 = cas.createAnnotation(t1, 5, 9);
cas.addFsToIndexes(a1);
int ref = 0;
- if (a1 instanceof AnnotationImpl) {
- AnnotationImpl aImpl = (AnnotationImpl) a1;
+ if (a1 instanceof Annotation) {
+ Annotation aImpl = (Annotation) a1;
ref = aImpl.getAddress();
}
@@ -91,8 +91,7 @@
featureMap.put(typeName, list);
String fn = "a";
list.add(new TestFeature(fn, "", "uima.tcas.Annotation"));
-
-
+
CAS cas = null;
try {
cas = RutaTestUtils.getCAS(document, typeMap, featureMap);
@@ -103,13 +102,13 @@
AnnotationFS a1 = cas.createAnnotation(t1, 5, 9);
cas.addFsToIndexes(a1);
int ref = 0;
- if (a1 instanceof AnnotationImpl) {
- AnnotationImpl aImpl = (AnnotationImpl) a1;
+ if (a1 instanceof Annotation) {
+ Annotation aImpl = (Annotation) a1;
ref = aImpl.getAddress();
}
String script = "";
- script += "CREATE(Struct, \"a\" = $"+ref+");";
+ script += "CREATE(Struct, \"a\" = $" + ref + ");";
try {
Ruta.apply(cas, script);
} catch (Exception e) {
@@ -137,5 +136,5 @@
}
}
-
+
}
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationFeatureExpressionTest.java b/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationFeatureExpressionTest.java
index 715c40f..0d24944 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationFeatureExpressionTest.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationFeatureExpressionTest.java
@@ -175,7 +175,7 @@
AnnotationFS a2 = cas.createAnnotation(type1, 5, 9);
FeatureStructure fs1 = cas.createFS(type2);
FeatureStructure fs2 = cas.createFS(type2);
- FSArray fsArray1 = FSCollectionFactory.createFSArray(cas.getJCas(),
+ FSArray<FeatureStructure> fsArray1 = FSCollectionFactory.createFSArray(cas.getJCas(),
new FeatureStructure[] { fs1, fs2 });
fs1.setStringValue(type2s, "1");
fs2.setStringValue(type2s, "2");
@@ -236,7 +236,7 @@
CAS cas = RutaTestUtils.getCAS(document, complexTypes, features);
Ruta.apply(cas, script);
- RutaTestUtils.assertAnnotationsEquals(cas, 1,1, "a");
+ RutaTestUtils.assertAnnotationsEquals(cas, 1, 1, "a");
}
@Test
@@ -257,19 +257,18 @@
features.put("Struct1", struct1Features);
struct1Features.add(new TestFeature("smallW", "", "uima.cas.FSArray"));
struct1Features.add(new TestFeature("capitalW", "", "uima.cas.FSArray"));
-
+
List<TestFeature> wordFeatures = new ArrayList<RutaTestUtils.TestFeature>();
features.put("Word", wordFeatures);
wordFeatures.add(new TestFeature("small", "", "uima.cas.Boolean"));
-
+
CAS cas = RutaTestUtils.getCAS(document, complexTypes, features);
Ruta.apply(cas, script);
-
+
RutaTestUtils.assertAnnotationsEquals(cas, 1, 2, "is", "a");
RutaTestUtils.assertAnnotationsEquals(cas, 2, 2, "This", "Test");
}
-
-
+
@Test
public void testPartofOnNullMatch() throws Exception {
String document = "Some text.";
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationLabelExpressionTest.java b/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationLabelExpressionTest.java
index 27f8dde..c4738aa 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationLabelExpressionTest.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationLabelExpressionTest.java
@@ -441,7 +441,7 @@
FeatureStructure featureValueA = null;
FeatureStructure featureValueAS = null;
Annotation a = null;
- FSArray as = null;
+ FSArray<?> as = null;
type = cas.getTypeSystem().getType("Struct1");
featureA = type.getFeatureByBaseName("a");
@@ -457,7 +457,7 @@
Assert.assertTrue(featureValueA instanceof Annotation);
Assert.assertTrue(featureValueAS instanceof FSArray);
a = (Annotation) featureValueA;
- as = (FSArray) featureValueAS;
+ as = (FSArray<?>) featureValueAS;
Assert.assertEquals("Some text", a.getCoveredText());
Assert.assertEquals("Annotation", a.getType().getShortName());
Assert.assertEquals(1, as.size());
@@ -478,7 +478,7 @@
Assert.assertTrue(featureValueA instanceof Annotation);
Assert.assertTrue(featureValueAS instanceof FSArray);
a = (Annotation) featureValueA;
- as = (FSArray) featureValueAS;
+ as = (FSArray<?>) featureValueAS;
Assert.assertEquals("Some", a.getCoveredText());
Assert.assertEquals("CW", a.getType().getShortName());
Assert.assertEquals(2, as.size());
@@ -501,7 +501,7 @@
Assert.assertTrue(featureValueA instanceof Annotation);
Assert.assertTrue(featureValueAS instanceof FSArray);
a = (Annotation) featureValueA;
- as = (FSArray) featureValueAS;
+ as = (FSArray<?>) featureValueAS;
Assert.assertEquals("Some text", a.getCoveredText());
Assert.assertEquals("Annotation", a.getType().getShortName());
Assert.assertEquals(1, as.size());
@@ -795,4 +795,54 @@
}
+ @Test
+ public void testComplexLabelReset() throws Exception {
+ // UIMA-6262
+ // Enumeration
+ // <-{dc1:DiagnosisConcept{dc1.negatedBy!=null}; cue:dc1.negatedBy;}
+ // ->{dc2:DiagnosisConcept{dc2.negatedBy==null -> dc2.negatedBy=cue};
+ // };
+ // solved by rewriting
+
+ String document = "Test 1. Test 2. Test 3. Test 4.";
+
+ String script = "";
+ script += "ANY+{-PARTOF(T1),-PARTOF(PERIOD)-> T1};\n";
+ script += "T1<-{n1:NUM{REGEXP(\"1|3\")};}<-{n2:n1;}\n"; // one applies always
+ script += "->{n2{->T2};};"; //
+
+ CAS cas = RutaTestUtils.getCAS(document);
+ Ruta.apply(cas, script);
+ RutaTestUtils.assertAnnotationsEquals(cas, 2, 2, "1", "3");
+ }
+
+ @Test
+ public void testImplicitNullCheck() throws Exception {
+
+ String document = "CW sw 1";
+
+ String script = "";
+ script += "(w:W n:NUM?){n!=null -> T1};";
+ script += "(w:W n:NUM?){n==null -> T2};";
+
+ CAS cas = RutaTestUtils.getCAS(document);
+ Ruta.apply(cas, script);
+
+ RutaTestUtils.assertAnnotationsEquals(cas, 1, 1, "sw 1");
+ RutaTestUtils.assertAnnotationsEquals(cas, 2, 1, "CW");
+ }
+
+ @Test
+ @Ignore
+ public void testInlineWithQuantifier() throws Exception {
+
+ String script = "";
+ script += "CW{-> Struct1, Struct1.a=sw} sw:SW;\n";
+ script += "sw:SW{-> Struct1, Struct1.a=sw};\n";
+ script += "p:PERIOD{-> Struct1, Struct1.a=p};\n";
+ script += "(s1:Struct1<-{u1:s1.a;} (s2:Struct1<-{u2:s2.a{u2.ct==u1.ct};})+){-> T1};\n";
+ CAS cas = this.applyOnStruct4Cas(script);
+ RutaTestUtils.assertAnnotationsEquals(cas, 1, 1, "Some text");
+ }
+
}
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationVariableExpressionTest.java b/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationVariableExpressionTest.java
index 1897e50..34da8e5 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationVariableExpressionTest.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/expression/annotation/AnnotationVariableExpressionTest.java
@@ -163,7 +163,7 @@
iterator = ai.iterator();
next = iterator.next();
assertEquals("text", next.getCoveredText());
- FSArray array = (FSArray) next.getFeatureValue(f1);
+ FSArray<?> array = (FSArray<?>) next.getFeatureValue(f1);
assertNotNull("Feature value is null!", array);
assertEquals(2, array.size());
}
@@ -204,7 +204,7 @@
iterator = ai.iterator();
next = iterator.next();
assertEquals("text", next.getCoveredText());
- FSArray array = (FSArray) next.getFeatureValue(f1);
+ FSArray<?> array = (FSArray<?>) next.getFeatureValue(f1);
assertNotNull("Feature value is null!", array);
assertEquals(2, array.size());
}
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/expression/feature/FeatureStructureTest.java b/ruta-core/src/test/java/org/apache/uima/ruta/expression/feature/FeatureStructureTest.java
index bb31678..cf6164e 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/expression/feature/FeatureStructureTest.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/expression/feature/FeatureStructureTest.java
@@ -38,7 +38,6 @@
public class FeatureStructureTest {
-
@Test
public void testFeatureStructureFeature() throws Exception {
@@ -79,7 +78,7 @@
AnnotationFS a2 = cas.createAnnotation(type1, 5, 9);
FeatureStructure fs1 = cas.createFS(type2);
FeatureStructure fs2 = cas.createFS(type2);
- FSArray fsArray1 = FSCollectionFactory.createFSArray(cas.getJCas(),
+ FSArray<FeatureStructure> fsArray1 = FSCollectionFactory.createFSArray(cas.getJCas(),
new FeatureStructure[] { fs1, fs2 });
fs1.setStringValue(type2s, "1");
fs2.setStringValue(type2s, "2");
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/rule/ConjunctRulesTest.java b/ruta-core/src/test/java/org/apache/uima/ruta/rule/ConjunctRulesTest.java
index 2da50fa..1d4561f 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/rule/ConjunctRulesTest.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/rule/ConjunctRulesTest.java
@@ -116,4 +116,33 @@
RutaTestUtils.assertAnnotationsEquals(cas, 2, 8, "A", "A", "B", "B", "B", "B", "A", "A");
}
+ @Test
+ public void testFirstElementMatches() throws Exception {
+
+ String document = "a Bb a Bb";
+ CAS cas = RutaTestUtils.getCAS(document);
+
+ Ruta.apply(cas, "SW{-> T1} % CW{-> T3} CW{-> T4};");
+
+ RutaTestUtils.assertAnnotationsEquals(cas, 1, 0);
+ RutaTestUtils.assertAnnotationsEquals(cas, 2, 0);
+ RutaTestUtils.assertAnnotationsEquals(cas, 3, 0);
+ RutaTestUtils.assertAnnotationsEquals(cas, 4, 0);
+
+ Ruta.apply(cas, "CW{-> T1} CW{-> T2} % SW{-> T3};");
+
+ RutaTestUtils.assertAnnotationsEquals(cas, 1, 0);
+ RutaTestUtils.assertAnnotationsEquals(cas, 2, 0);
+ RutaTestUtils.assertAnnotationsEquals(cas, 3, 0);
+ RutaTestUtils.assertAnnotationsEquals(cas, 4, 0);
+
+ Ruta.apply(cas, "SW{-> T1} SW{-> T2} % CW{-> T3} CW{-> T4};");
+
+ RutaTestUtils.assertAnnotationsEquals(cas, 1, 0);
+ RutaTestUtils.assertAnnotationsEquals(cas, 2, 0);
+ RutaTestUtils.assertAnnotationsEquals(cas, 3, 0);
+ RutaTestUtils.assertAnnotationsEquals(cas, 4, 0);
+
+ }
+
}
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/rule/RuleInference1Test.java b/ruta-core/src/test/java/org/apache/uima/ruta/rule/RuleInference1Test.java
index 02b9835..4c8d2bf 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/rule/RuleInference1Test.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/rule/RuleInference1Test.java
@@ -24,7 +24,6 @@
import org.junit.Test;
public class RuleInference1Test {
-
@Test
public void test() {
@@ -33,18 +32,23 @@
RutaTestUtils.assertAnnotationsEquals(cas, 1, 4, "Peter", "Jochen", "Flo", "Georg");
RutaTestUtils.assertAnnotationsEquals(cas, 2, 1, "und");
RutaTestUtils.assertAnnotationsEquals(cas, 3, 0);
- RutaTestUtils.assertAnnotationsEquals(cas, 4, 5, "Peter", "Jochen", "Flo und Georg", "und Georg", "Georg");
+ RutaTestUtils.assertAnnotationsEquals(cas, 4, 5, "Peter", "Jochen", "Flo und Georg",
+ "und Georg", "Georg");
RutaTestUtils.assertAnnotationsEquals(cas, 5, 2, ",", ",");
RutaTestUtils.assertAnnotationsEquals(cas, 6, 2, "Peter, Jochen,", "Jochen,");
RutaTestUtils.assertAnnotationsEquals(cas, 7, 5, "Peter", "Jochen", "Flo", "und", "Georg");
- RutaTestUtils.assertAnnotationsEquals(cas, 8, 5, "Peter", "Jochen", "Flo und Georg", "und Georg", "Georg");
+ RutaTestUtils.assertAnnotationsEquals(cas, 8, 5, "Peter", "Jochen", "Flo und Georg",
+ "und Georg", "Georg");
RutaTestUtils.assertAnnotationsEquals(cas, 9, 2, "Peter, Jochen, Flo", "Jochen, Flo");
- RutaTestUtils.assertAnnotationsEquals(cas, 10, 3, "Peter, Jochen, Flo und", "Jochen, Flo und", "Flo und");
- RutaTestUtils.assertAnnotationsEquals(cas, 11, 3, "Peter, Jochen, Flo und Georg.", "Jochen, Flo und Georg.",
- "Flo und Georg.");
+ RutaTestUtils.assertAnnotationsEquals(cas, 10, 3, "Peter, Jochen, Flo und", "Jochen, Flo und",
+ "Flo und");
+ RutaTestUtils.assertAnnotationsEquals(cas, 11, 3, "Peter, Jochen, Flo und Georg.",
+ "Jochen, Flo und Georg.", "Flo und Georg.");
RutaTestUtils.assertAnnotationsEquals(cas, 12, 6, ",", ",", ",", "und", "und", "und");
- RutaTestUtils.assertAnnotationsEquals(cas, 13, 6, "Peter,", "Jochen,", "Jochen,", "Flo und", "Flo und", "Flo und");
- RutaTestUtils.assertAnnotationsEquals(cas, 14, 3, "Peter, Jochen, Flo und", "Jochen, Flo und", "Flo und");
+ RutaTestUtils.assertAnnotationsEquals(cas, 13, 6, "Peter,", "Jochen,", "Jochen,", "Flo und",
+ "Flo und", "Flo und");
+ RutaTestUtils.assertAnnotationsEquals(cas, 14, 3, "Peter, Jochen, Flo und", "Jochen, Flo und",
+ "Flo und");
RutaTestUtils.assertAnnotationsEquals(cas, 15, 1, "Peter, Jochen");
RutaTestUtils.assertAnnotationsEquals(cas, 16, 1, "Georg.");
RutaTestUtils.assertAnnotationsEquals(cas, 17, 1, "Flo und Georg.");
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/rule/WildCard2Test.java b/ruta-core/src/test/java/org/apache/uima/ruta/rule/WildCard2Test.java
index 720670b..38dabdf 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/rule/WildCard2Test.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/rule/WildCard2Test.java
@@ -272,6 +272,18 @@
}
@Test
+ public void testLabelForFailedLookahead() throws Exception {
+ String document = "A x B x C x D";
+ String script = "(w1:CW{REGEXP(\"A\")} # w2:CW{REGEXP(\"C\")})->{w1{->T1};};";
+
+ CAS cas = RutaTestUtils.getCAS(document, null, null, false);
+ Ruta.apply(cas, script);
+
+ RutaTestUtils.assertAnnotationsEquals(cas, 1, 1, "A");
+ }
+
+
+ @Test
public void testLastElementAlsoAnnotatedWithLookahead() throws Exception {
String document = "a b c. a b c.";
String script = "ANY+{-PARTOF({PERIOD, T1})->T1};\n";
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/visitor/DebugAddToIndexesTest.java b/ruta-core/src/test/java/org/apache/uima/ruta/visitor/DebugAddToIndexesTest.java
new file mode 100644
index 0000000..41b5139
--- /dev/null
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/visitor/DebugAddToIndexesTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.ruta.visitor;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.fit.util.JCasUtil;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.ruta.engine.Ruta;
+import org.apache.uima.ruta.engine.RutaEngine;
+import org.apache.uima.ruta.engine.RutaTestUtils;
+import org.apache.uima.ruta.type.DebugRuleApply;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DebugAddToIndexesTest {
+
+ @Test
+ public void test() throws Exception {
+
+ String document = "This is a test.";
+ String script = "";
+ script += "CW;";
+
+ CAS cas = RutaTestUtils.getCAS(document);
+ Map<String, Object> parameters = new HashMap<>();
+ parameters.put(RutaEngine.PARAM_DEBUG, Boolean.TRUE);
+ parameters.put(RutaEngine.PARAM_DEBUG_WITH_MATCHES, Boolean.TRUE);
+ parameters.put(RutaEngine.PARAM_DEBUG_ADD_TO_INDEXES, Boolean.TRUE);
+
+ Ruta.apply(cas, script, parameters);
+
+ JCas jcas = cas.getJCas();
+
+ Collection<DebugRuleApply> debugRuleApplies = JCasUtil.select(jcas, DebugRuleApply.class);
+ Assert.assertEquals(3, debugRuleApplies.size());
+ Iterator<DebugRuleApply> iterator = debugRuleApplies.iterator();
+ iterator.next();
+ Assert.assertEquals("Document;", iterator.next().getElement());
+ Assert.assertEquals("CW;", iterator.next().getElement());
+ }
+}
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/visitor/InlinedRulesExplanationTest.java b/ruta-core/src/test/java/org/apache/uima/ruta/visitor/InlinedRulesExplanationTest.java
index 3c14a6d..36e097a 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/visitor/InlinedRulesExplanationTest.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/visitor/InlinedRulesExplanationTest.java
@@ -32,10 +32,12 @@
import org.apache.uima.ruta.engine.RutaEngine;
import org.apache.uima.ruta.engine.RutaTestUtils;
import org.apache.uima.ruta.type.DebugBlockApply;
+import org.apache.uima.ruta.type.DebugInlinedBlock;
import org.apache.uima.ruta.type.DebugMatchedRuleMatch;
import org.apache.uima.ruta.type.DebugRuleApply;
import org.apache.uima.ruta.type.DebugRuleElementMatch;
import org.apache.uima.ruta.type.DebugRuleElementMatches;
+import org.apache.uima.ruta.type.DebugRuleMatch;
import org.apache.uima.ruta.type.DebugScriptApply;
import org.junit.Assert;
import org.junit.Test;
@@ -64,20 +66,20 @@
Assert.assertTrue(debugScriptApply instanceof DebugBlockApply);
DebugBlockApply debugBlockApply = (DebugBlockApply) debugScriptApply;
- FSArray innerApply = debugBlockApply.getInnerApply();
+ FSArray<DebugScriptApply> innerApply = debugBlockApply.getInnerApply();
Assert.assertEquals(1, innerApply.size());
FeatureStructure innerApplyFS = innerApply.get(0);
Assert.assertTrue(debugScriptApply instanceof DebugRuleApply);
DebugRuleApply debugRuleApply = (DebugRuleApply) innerApplyFS;
- FSArray rules = debugRuleApply.getRules();
+ FSArray<DebugRuleMatch> rules = debugRuleApply.getRules();
Assert.assertEquals(1, rules.size());
FeatureStructure ruleMatchFS = rules.get(0);
Assert.assertTrue(ruleMatchFS instanceof DebugMatchedRuleMatch);
DebugMatchedRuleMatch debugMatchedRuleMatch = (DebugMatchedRuleMatch) ruleMatchFS;
Assert.assertEquals(0, debugMatchedRuleMatch.getDelegates().size());
- FSArray reMatchesArray = debugMatchedRuleMatch.getElements();
+ FSArray<DebugRuleElementMatches> reMatchesArray = debugMatchedRuleMatch.getElements();
Assert.assertEquals(2, reMatchesArray.size());
FeatureStructure reMatches1FS = reMatchesArray.get(0);
FeatureStructure reMatches2FS = reMatchesArray.get(1);
@@ -86,8 +88,8 @@
DebugRuleElementMatches re1Matches = (DebugRuleElementMatches) reMatches1FS;
DebugRuleElementMatches re2Matches = (DebugRuleElementMatches) reMatches2FS;
- FSArray inlinedActionRules1 = re1Matches.getInlinedActionBlocks();
- FSArray inlinedActionRules2 = re2Matches.getInlinedActionBlocks();
+ FSArray<DebugInlinedBlock> inlinedActionRules1 = re1Matches.getInlinedActionBlocks();
+ FSArray<DebugInlinedBlock> inlinedActionRules2 = re2Matches.getInlinedActionBlocks();
Assert.assertEquals(1, inlinedActionRules1.size());
Assert.assertEquals(2, inlinedActionRules2.size());
@@ -95,8 +97,8 @@
DebugRuleElementMatch re1Match = (DebugRuleElementMatch) re1Matches.getMatches().get(0);
DebugRuleElementMatch re2Match = (DebugRuleElementMatch) re2Matches.getMatches().get(0);
- FSArray inlinedConditionRules1 = re1Match.getInlinedConditionBlocks();
- FSArray inlinedConditionRules2 = re2Match.getInlinedConditionBlocks();
+ FSArray<DebugInlinedBlock> inlinedConditionRules1 = re1Match.getInlinedConditionBlocks();
+ FSArray<DebugInlinedBlock> inlinedConditionRules2 = re2Match.getInlinedConditionBlocks();
Assert.assertEquals(2, inlinedConditionRules1.size());
Assert.assertEquals(1, inlinedConditionRules2.size());
diff --git a/ruta-docbook/pom.xml b/ruta-docbook/pom.xml
index 7167bb7..9047352 100644
--- a/ruta-docbook/pom.xml
+++ b/ruta-docbook/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-parent/pom.xml</relativePath>
</parent>
<name>Apache UIMA Ruta Documentation</name>
diff --git a/ruta-docbook/src/docbook/tools.ruta.language.conditions.xml b/ruta-docbook/src/docbook/tools.ruta.language.conditions.xml
index 0083747..7203419 100644
--- a/ruta-docbook/src/docbook/tools.ruta.language.conditions.xml
+++ b/ruta-docbook/src/docbook/tools.ruta.language.conditions.xml
@@ -892,7 +892,7 @@
<emphasis role="bold">Definition:</emphasis>
</title>
<para>
- <programlisting><![CDATA[TOTALCOUNT(Type(,NumberExpression,NumberExpression(,Variable)?)?)]]></programlisting>
+ <programlisting><![CDATA[TOTALCOUNT(Type(,NumberExpression,NumberExpression)?(,NumberVariable)?)]]></programlisting>
</para>
</section>
<section>
diff --git a/ruta-docbook/src/docbook/tools.ruta.overview.xml b/ruta-docbook/src/docbook/tools.ruta.overview.xml
index ee2a5a0..ed30da0 100644
--- a/ruta-docbook/src/docbook/tools.ruta.overview.xml
+++ b/ruta-docbook/src/docbook/tools.ruta.overview.xml
@@ -959,6 +959,14 @@
</row>
<row>
<entry>
+ <link linkend='ugr.tools.ruta.ae.basic.parameter.typeIgnorePattern'>typeIgnorePattern</link>
+ </entry>
+ <entry>Option to ignore types even if they are available in the typesystem/CAS.
+ </entry>
+ <entry>Single String</entry>
+ </row>
+ <row>
+ <entry>
<link linkend='ugr.tools.ruta.ae.basic.parameter.dynamicAnchoring'>dynamicAnchoring</link>
</entry>
<entry>Option to allow rule matches to start at any rule element.</entry>
@@ -994,6 +1002,13 @@
</row>
<row>
<entry>
+ <link linkend='ugr.tools.ruta.ae.basic.parameter.debugAddToIndexes'>debugAddToIndexes</link>
+ </entry>
+ <entry>Option to add all debug information to the indexes.</entry>
+ <entry>Single Boolean</entry>
+ </row>
+ <row>
+ <entry>
<link linkend='ugr.tools.ruta.ae.basic.parameter.debugOnlyFor'>debugOnlyFor</link>
</entry>
<entry>List of rule ids. If provided, then debug information is only created for
@@ -1324,6 +1339,14 @@
The default value is set to false.
</para>
</section>
+ <section id="ugr.tools.ruta.ae.basic.parameter.typeIgnorePattern">
+ <title>typeIgnorePattern</title>
+ <para>
+ An optional pattern (regular expression) which defined types that should be ignored. These
+ types will not be resolved even if strictImports is set to false. This parameter can be used to
+ ignore complete namespaces of type that could contain ambiguous short names.
+ </para>
+ </section>
<section id="ugr.tools.ruta.ae.basic.parameter.dynamicAnchoring">
<title>dynamicAnchoring</title>
<para>
@@ -1363,6 +1386,13 @@
The default value of this parameter is set to false.
</para>
</section>
+ <section id="ugr.tools.ruta.ae.basic.parameter.debugAddToIndexes">
+ <title>debugAddToIndexes</title>
+ <para>
+ This parameter specifies whether all debug annotation should be added to the indexes. By
+ default this parameter is deactivated and only the root script apply is added.
+ </para>
+ </section>
<section id="ugr.tools.ruta.ae.basic.parameter.debugOnlyFor">
<title>debugOnlyFor</title>
<para>
diff --git a/ruta-eclipse-feature/pom.xml b/ruta-eclipse-feature/pom.xml
index 2bca59a..9ecb916 100644
--- a/ruta-eclipse-feature/pom.xml
+++ b/ruta-eclipse-feature/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-parent/pom.xml</relativePath>
</parent>
diff --git a/ruta-eclipse-update-site/pom.xml b/ruta-eclipse-update-site/pom.xml
index f92f3b8..ec8484e 100644
--- a/ruta-eclipse-update-site/pom.xml
+++ b/ruta-eclipse-update-site/pom.xml
@@ -30,7 +30,7 @@
<artifactId>ruta-eclipse-update-site</artifactId>
<packaging>pom</packaging>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<name>Apache UIMA Ruta Eclipse: ${project.artifactId}</name>
<description>The UIMA Ruta Eclipse update site</description>
diff --git a/ruta-ep-addons/pom.xml b/ruta-ep-addons/pom.xml
index 61259e7..c26a33c 100644
--- a/ruta-ep-addons/pom.xml
+++ b/ruta-ep-addons/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-ep-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-ep-parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/ruta-ep-caseditor/pom.xml b/ruta-ep-caseditor/pom.xml
index 4a5843f..2df0e43 100644
--- a/ruta-ep-caseditor/pom.xml
+++ b/ruta-ep-caseditor/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-ep-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-ep-parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/ruta-ep-core-ext/pom.xml b/ruta-ep-core-ext/pom.xml
index c422ab9..018a76a 100644
--- a/ruta-ep-core-ext/pom.xml
+++ b/ruta-ep-core-ext/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-ep-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-ep-parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/ruta-ep-engine/pom.xml b/ruta-ep-engine/pom.xml
index 8a355dd..8177277 100644
--- a/ruta-ep-engine/pom.xml
+++ b/ruta-ep-engine/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-parent/pom.xml</relativePath>
</parent>
diff --git a/ruta-ep-ide-ui/pom.xml b/ruta-ep-ide-ui/pom.xml
index c2b59ab..92ac08d 100644
--- a/ruta-ep-ide-ui/pom.xml
+++ b/ruta-ep-ide-ui/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-ep-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-ep-parent/pom.xml</relativePath>
</parent>
diff --git a/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java b/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java
index 6386199..cb2d864 100644
--- a/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java
+++ b/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java
@@ -92,7 +92,8 @@
IPath outputDirPath = projectPath.append(RutaProjectUtils.getDefaultOutputLocation());
Collection<String> classPath = RutaProjectUtils.getClassPath(proj.getProject());
ClassLoader classLoader = RutaProjectUtils.getClassLoader(classPath);
- IPath analysisEngineDescriptorPath = RutaProjectUtils.getAnalysisEngineDescriptorPath(member.getLocation(), proj.getProject(), classLoader);
+ IPath analysisEngineDescriptorPath = RutaProjectUtils
+ .getAnalysisEngineDescriptorPath(member.getLocation(), proj.getProject(), classLoader);
String engineDefaultMethod = "null";
if (analysisEngineDescriptorPath != null) {
engineDefaultMethod = analysisEngineDescriptorPath.toPortableString();
@@ -107,8 +108,7 @@
if (StringUtils.isBlank(output)) {
output = outputDirPath.toPortableString();
}
- String engine = configuration.getAttribute(RutaLaunchConstants.DESCRIPTOR,
- engineDefaultMethod);
+ String engine = configuration.getAttribute(RutaLaunchConstants.DESCRIPTOR, engineDefaultMethod);
if (StringUtils.isBlank(engine)) {
engine = engineDefaultMethod;
}
@@ -152,7 +152,7 @@
cmdline.append(RutaLaunchConstants.FORMAT + " ");
cmdline.append(defaultFormat + " ");
-
+
return cmdline.toString();
}
@@ -345,15 +345,15 @@
// RutaIdeUIPlugin.error(e1);
// }
// } else {
- super.launch(configuration, mode, launch, monitor);
+ super.launch(configuration, mode, launch, monitor);
- while (!launch.isTerminated()) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- Thread.interrupted();
- }
+ while (!launch.isTerminated()) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ Thread.interrupted();
}
+ }
// }
if (ouputFolder != null) {
ouputFolder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
@@ -386,4 +386,9 @@
return result;
}
+ @Override
+ protected boolean supportsModule() {
+ return false;
+ }
+
}
diff --git a/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/RutaCodeScanner.java b/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/RutaCodeScanner.java
index 94714ff..dcb296a 100644
--- a/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/RutaCodeScanner.java
+++ b/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/RutaCodeScanner.java
@@ -35,11 +35,12 @@
private static String fgTokenProperties[] = new String[] {
RutaColorConstants.RUTA_SINGLE_LINE_COMMENT, RutaColorConstants.RUTA_DEFAULT,
- RutaColorConstants.RUTA_KEYWORD, RutaColorConstants.RUTA_KEYWORD_RETURN,
- RutaColorConstants.RUTA_NUMBER, RutaColorConstants.RUTA_FUNCTION,
- RutaColorConstants.RUTA_CONDITION, RutaColorConstants.RUTA_ACTION,
- RutaColorConstants.RUTA_RULE, RutaColorConstants.RUTA_DECLARATION,
- RutaColorConstants.RUTA_BASICSYMBOL, RutaColorConstants.RUTA_THEN };
+ RutaColorConstants.RUTA_DEFAULT_ECLIPSE, RutaColorConstants.RUTA_KEYWORD,
+ RutaColorConstants.RUTA_KEYWORD_RETURN, RutaColorConstants.RUTA_NUMBER,
+ RutaColorConstants.RUTA_FUNCTION, RutaColorConstants.RUTA_CONDITION,
+ RutaColorConstants.RUTA_ACTION, RutaColorConstants.RUTA_RULE,
+ RutaColorConstants.RUTA_DECLARATION, RutaColorConstants.RUTA_BASICSYMBOL,
+ RutaColorConstants.RUTA_THEN };
public RutaCodeScanner(IColorManager manager, IPreferenceStore store) {
super(manager, store);
@@ -57,7 +58,8 @@
IToken keyword = getToken(RutaColorConstants.RUTA_KEYWORD);
IToken rule = getToken(RutaColorConstants.RUTA_RULE);
IToken comment = getToken(RutaColorConstants.RUTA_SINGLE_LINE_COMMENT);
- IToken other = getToken(RutaColorConstants.RUTA_DEFAULT);
+// IToken other = getToken(RutaColorConstants.RUTA_DEFAULT);
+ IToken defaultToken = getToken(RutaColorConstants.RUTA_DEFAULT_ECLIPSE);
IToken declaration = getToken(RutaColorConstants.RUTA_DECLARATION);
IToken basicSymbol = getToken(RutaColorConstants.RUTA_BASICSYMBOL);
IToken function = getToken(RutaColorConstants.RUTA_FUNCTION);
@@ -70,7 +72,7 @@
// rules.add(new MultiLineRule("/*", "*/", comment, '\\', true));
// rules.add(new EndOfLineRule("//", comment));
rules.add(new WhitespaceRule(new RutaWhitespaceDetector()));
- RutaWordRule wordRule = new RutaWordRule(new RutaWordDetector(), other, rule);
+ RutaWordRule wordRule = new RutaWordRule(new RutaWordDetector(), defaultToken, rule);
for (String each : RutaKeywordsManager.getKeywords(IRutaKeywords.CONDITION)) {
wordRule.addWord(each, condition);
@@ -101,7 +103,7 @@
}
rules.add(wordRule);
- setDefaultReturnToken(other);
+ setDefaultReturnToken(defaultToken);
return rules;
}
}
diff --git a/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/RutaColorConstants.java b/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/RutaColorConstants.java
index 74ae4d4..0591a78 100644
--- a/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/RutaColorConstants.java
+++ b/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/RutaColorConstants.java
@@ -40,6 +40,8 @@
public static final String RUTA_DEFAULT = DLTKColorConstants.DLTK_DEFAULT;
+ public static final String RUTA_DEFAULT_ECLIPSE = "AbstractTextEditor.Color.Foreground";
+
public static final String RUTA_CONDITION = "ruta_condition"; //$NON-NLS-1$
public static final String RUTA_ACTION = "ruta_action"; //$NON-NLS-1$
diff --git a/ruta-ep-ide/pom.xml b/ruta-ep-ide/pom.xml
index d4278e8..bd1e95a 100644
--- a/ruta-ep-ide/pom.xml
+++ b/ruta-ep-ide/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-ep-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-ep-parent/pom.xml</relativePath>
</parent>
diff --git a/ruta-ep-parent/pom.xml b/ruta-ep-parent/pom.xml
index 5d3384e..a403478 100644
--- a/ruta-ep-parent/pom.xml
+++ b/ruta-ep-parent/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-parent/pom.xml</relativePath>
</parent>
diff --git a/ruta-ep-textruler/pom.xml b/ruta-ep-textruler/pom.xml
index 688b949..8c416b9 100644
--- a/ruta-ep-textruler/pom.xml
+++ b/ruta-ep-textruler/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-ep-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-ep-parent/pom.xml</relativePath>
</parent>
diff --git a/ruta-maven-archetype/pom.xml b/ruta-maven-archetype/pom.xml
index 2b918f8..bc994d4 100644
--- a/ruta-maven-archetype/pom.xml
+++ b/ruta-maven-archetype/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/ruta-maven-plugin/pom.xml b/ruta-maven-plugin/pom.xml
index 93b357a..f0ab63e 100644
--- a/ruta-maven-plugin/pom.xml
+++ b/ruta-maven-plugin/pom.xml
@@ -34,7 +34,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/ruta-parent/pom.xml b/ruta-parent/pom.xml
index d9e1765..adeb069 100644
--- a/ruta-parent/pom.xml
+++ b/ruta-parent/pom.xml
@@ -31,7 +31,7 @@
<artifactId>ruta-parent</artifactId>
<packaging>pom</packaging>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<name>Apache UIMA Ruta: ${project.artifactId}</name>
<url>${uimaWebsiteUrl}</url>
<inceptionYear>2011</inceptionYear>
@@ -114,15 +114,25 @@
(http://www.famfamfam.com/lab/icons/silk/), licensed under the
Creative Commons Attribution 3.0 License.
</postNoticeText>
- <uimaVersion>3.2.0-SNAPSHOT</uimaVersion>
- <uimafit-version>3.2.0-SNAPSHOT</uimafit-version>
+
+ <uimaVersion>3.2.0</uimaVersion>
+ <uimafit-version>3.2.0</uimafit-version>
<spring-version>4.3.30.RELEASE</spring-version>
+ <!--
+ BACKWARD_COMPATIBLE_IMPLEMENTER - patch version (=.=.+)
+ BACKWARD_COMPATIBLE_USER - minor version (=.+.0)
+ NON_BACKWARD_COMPATIBLE - major version (+.0.0)
+ -->
+
+ <compat.level>BACKWARD_COMPATIBLE_USER</compat.level>
+ <compat.previous.version>3.0.1</compat.previous.version>
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
- <api_check_oldVersion>2.6.1</api_check_oldVersion>
+ <api_check_oldVersion>3.0.1</api_check_oldVersion>
</properties>
<dependencyManagement>
diff --git a/ruta-typesystem/pom.xml b/ruta-typesystem/pom.xml
index 10bb713..102bce6 100644
--- a/ruta-typesystem/pom.xml
+++ b/ruta-typesystem/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../ruta-parent/pom.xml</relativePath>
</parent>
diff --git a/ruta-typesystem/src/main/resources/org/apache/uima/ruta/engine/RutaInternalTypeSystem.xml b/ruta-typesystem/src/main/resources/org/apache/uima/ruta/engine/RutaInternalTypeSystem.xml
index 902077f..dd6e351 100644
--- a/ruta-typesystem/src/main/resources/org/apache/uima/ruta/engine/RutaInternalTypeSystem.xml
+++ b/ruta-typesystem/src/main/resources/org/apache/uima/ruta/engine/RutaInternalTypeSystem.xml
@@ -295,9 +295,14 @@
<features>
<featureDescription>
<name>original</name>
- <description/>
+ <description>The annotation that caused this outcome.</description>
<rangeTypeName>uima.tcas.Annotation</rangeTypeName>
</featureDescription>
+ <featureDescription>
+ <name>group</name>
+ <description>Identifier for the group of annotations and types in the evaluation.</description>
+ <rangeTypeName>uima.cas.String</rangeTypeName>
+ </featureDescription>
</features>
</typeDescription>
<typeDescription>