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 2013/01/15 17:09:59 UTC
svn commit: r1433483 - in
/uima/sandbox/TextMarker/trunk/uimaj-textmarker/src:
main/java/org/apache/uima/textmarker/condition/
test/java/org/apache/uima/textmarker/condition/
test/resources/org/apache/uima/textmarker/condition/
Author: pkluegl
Date: Tue Jan 15 16:09:58 2013
New Revision: 1433483
URL: http://svn.apache.org/viewvc?rev=1433483&view=rev
Log:
UIMA-2507
- rewrote test for FEATURE condition
- fixed minor bug in condition factory
Modified:
uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java
uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/java/org/apache/uima/textmarker/condition/FeatureTest.java
uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/condition/FeatureTest.tm
uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/condition/FeatureTest.txt
Modified: uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java?rev=1433483&r1=1433482&r2=1433483&view=diff
==============================================================================
--- uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java (original)
+++ uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java Tue Jan 15 16:09:58 2013
@@ -164,10 +164,10 @@ public class ConditionFactory {
TextMarkerBlock parent) {
if (v instanceof NumberExpression) {
return new FeatureCondition(se, (NumberExpression) v);
- } else if (v instanceof StringExpression) {
- return new FeatureCondition(se, (StringExpression) v);
} else if (v instanceof BooleanExpression) {
return new FeatureCondition(se, (BooleanExpression) v);
+ } else if (v instanceof StringExpression) {
+ return new FeatureCondition(se, (StringExpression) v);
}
return null;
}
Modified: uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/java/org/apache/uima/textmarker/condition/FeatureTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/java/org/apache/uima/textmarker/condition/FeatureTest.java?rev=1433483&r1=1433482&r2=1433483&view=diff
==============================================================================
--- uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/java/org/apache/uima/textmarker/condition/FeatureTest.java (original)
+++ uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/java/org/apache/uima/textmarker/condition/FeatureTest.java Tue Jan 15 16:09:58 2013
@@ -21,12 +21,18 @@ package org.apache.uima.textmarker.condi
import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.FSIterator;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.cas.text.AnnotationIndex;
import org.apache.uima.textmarker.TextMarkerTestUtils;
+import org.apache.uima.textmarker.TextMarkerTestUtils.TestFeature;
import org.junit.Test;
public class FeatureTest {
@@ -36,10 +42,26 @@ public class FeatureTest {
String name = this.getClass().getSimpleName();
String namespace = this.getClass().getPackage().getName().replaceAll("\\.", "/");
+ Map<String, String> complexTypes = new TreeMap<String, String>();
+ String typeName = "org.apache.uima.FS";
+ complexTypes.put(typeName, "uima.tcas.Annotation");
+
+ Map<String, List<TestFeature>> features = new TreeMap<String, List<TestFeature>>();
+ List<TestFeature> list = new ArrayList<TextMarkerTestUtils.TestFeature>();
+ features.put(typeName, list);
+ String fn1 = "string";
+ list.add(new TestFeature(fn1, "", "uima.cas.String"));
+ String fn2 = "double";
+ list.add(new TestFeature(fn2, "", "uima.cas.Double"));
+ String fn3 = "int";
+ list.add(new TestFeature(fn3, "", "uima.cas.Integer"));
+ String fn4 = "boolean";
+ list.add(new TestFeature(fn4, "", "uima.cas.Boolean"));
+
CAS cas = null;
try {
cas = TextMarkerTestUtils.process(namespace + "/" + name + ".tm", namespace + "/" + name
- + ".txt", 50);
+ + ".txt", 50, false, false, complexTypes, features, namespace + "/");
} catch (Exception e) {
e.printStackTrace();
assert (false);
@@ -52,14 +74,29 @@ public class FeatureTest {
ai = cas.getAnnotationIndex(t);
assertEquals(1, ai.size());
iterator = ai.iterator();
- assertEquals("What features do these sentences have?\r\n" +
- "You can test this with the FEATURE condition.", iterator.next().getCoveredText());
+ assertEquals("Testing FEATURE condition.", iterator.next().getCoveredText());
t = TextMarkerTestUtils.getTestType(cas, 2);
ai = cas.getAnnotationIndex(t);
assertEquals(1, ai.size());
iterator = ai.iterator();
- assertEquals("You can test this with the FEATURE condition.", iterator.next().getCoveredText());
+ assertEquals("Testing FEATURE condition.", iterator.next().getCoveredText());
+
+ t = TextMarkerTestUtils.getTestType(cas, 3);
+ ai = cas.getAnnotationIndex(t);
+ assertEquals(1, ai.size());
+ iterator = ai.iterator();
+ assertEquals("Testing FEATURE condition.", iterator.next().getCoveredText());
+
+ t = TextMarkerTestUtils.getTestType(cas, 4);
+ ai = cas.getAnnotationIndex(t);
+ assertEquals(1, ai.size());
+ iterator = ai.iterator();
+ assertEquals("Testing FEATURE condition.", iterator.next().getCoveredText());
+
+ t = TextMarkerTestUtils.getTestType(cas, 5);
+ ai = cas.getAnnotationIndex(t);
+ assertEquals(0, ai.size());
cas.release();
}
Modified: uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/condition/FeatureTest.tm
URL: http://svn.apache.org/viewvc/uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/condition/FeatureTest.tm?rev=1433483&r1=1433482&r2=1433483&view=diff
==============================================================================
--- uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/condition/FeatureTest.tm (original)
+++ uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/condition/FeatureTest.tm Tue Jan 15 16:09:58 2013
@@ -1,7 +1,18 @@
PACKAGE org.apache.uima;
-DECLARE T1, T2;
+DECLARE T1, T2, T3, T4, T5, T6, T7, T8, T9;
-Document{FEATURE("begin",0) -> MARK(T1)};
-Document{-> SETFEATURE("begin",40)};
-Document{FEATURE("begin",40) -> MARK(T2)};
\ No newline at end of file
+DECLARE Annotation FS (STRING string, DOUBLE double, INT int, BOOLEAN boolean);
+
+
+Document{-> CREATE(FS, "string" = "string", "double" = 0.5, "int" = 2, "boolean" = true)};
+
+FS{FEATURE("string", "string") -> MARK(T1)};
+FS{FEATURE("double", 0.5) -> MARK(T2)};
+FS{FEATURE("int", 2) -> MARK(T3)};
+FS{FEATURE("boolean", true) -> MARK(T4)};
+
+FS{FEATURE("string", "") -> MARK(T5)};
+FS{FEATURE("double", 0.6) -> MARK(T5)};
+FS{FEATURE("int", 3) -> MARK(T5)};
+FS{FEATURE("boolean", false) -> MARK(T5)};
\ No newline at end of file
Modified: uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/condition/FeatureTest.txt
URL: http://svn.apache.org/viewvc/uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/condition/FeatureTest.txt?rev=1433483&r1=1433482&r2=1433483&view=diff
==============================================================================
--- uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/condition/FeatureTest.txt (original)
+++ uima/sandbox/TextMarker/trunk/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/condition/FeatureTest.txt Tue Jan 15 16:09:58 2013
@@ -1,2 +1 @@
-What features do these sentences have?
-You can test this with the FEATURE condition.
\ No newline at end of file
+Testing FEATURE condition.
\ No newline at end of file