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 2014/09/25 13:05:50 UTC

svn commit: r1627510 - /uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/ConjunctiveRuleElementTest.java

Author: pkluegl
Date: Thu Sep 25 11:05:50 2014
New Revision: 1627510

URL: http://svn.apache.org/r1627510
Log:
UIMA-4021
- added test (which fails right now)

Modified:
    uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/ConjunctiveRuleElementTest.java

Modified: uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/ConjunctiveRuleElementTest.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/ConjunctiveRuleElementTest.java?rev=1627510&r1=1627509&r2=1627510&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/ConjunctiveRuleElementTest.java (original)
+++ uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/ConjunctiveRuleElementTest.java Thu Sep 25 11:05:50 2014
@@ -21,6 +21,11 @@ package org.apache.uima.ruta;
 
 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;
@@ -28,6 +33,7 @@ import org.apache.uima.cas.text.Annotati
 import org.apache.uima.cas.text.AnnotationIndex;
 import org.apache.uima.ruta.engine.Ruta;
 import org.apache.uima.ruta.engine.RutaTestUtils;
+import org.apache.uima.ruta.engine.RutaTestUtils.TestFeature;
 import org.junit.Test;
 
 public class ConjunctiveRuleElementTest {
@@ -86,4 +92,52 @@ public class ConjunctiveRuleElementTest 
     }
 
   }
+  
+  @Test
+  public void testWithFeatureMatch() {
+    
+//    DECLARE Annotation Token (STRING posTag, STRING mood, STRING tense);    
+    String document = "Peter did something.";
+    String script = "";
+    script += "CW{-> CREATE(Token, \"posTag\" = \"noun\")} SW{-> CREATE(Token, \"posTag\" = \"verb\", \"mood\" = \"p\", \"tense\" = \"p\")} SW;\n";
+    script += "(Token.posTag == \"noun\" ( Token.posTag == \"verb\" & Token.mood==\"p\" & Token.tense==\"p\" )){-> T1};\n";
+    
+    Map<String, String> typeMap = new TreeMap<String, String>();
+    String typeName1 = "Token";
+    typeMap.put(typeName1, "uima.tcas.Annotation");
+
+    Map<String, List<TestFeature>> featureMap = new TreeMap<String, List<TestFeature>>();
+    List<TestFeature> list = new ArrayList<RutaTestUtils.TestFeature>();
+    featureMap.put(typeName1, list);
+    String fn1 = "posTag";
+    list.add(new TestFeature(fn1, "", "uima.cas.String"));
+    String fn2 = "mood";
+    list.add(new TestFeature(fn2, "", "uima.cas.String"));
+    String fn3 = "tense";
+    list.add(new TestFeature(fn3, "", "uima.cas.String"));
+    
+    CAS cas = null;
+    try {
+      cas = RutaTestUtils.getCAS(document, typeMap, featureMap);
+      Ruta.apply(cas, script);
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+
+    Type t = null;
+    AnnotationIndex<AnnotationFS> ai = null;
+    FSIterator<AnnotationFS> iterator = null;
+
+    t = RutaTestUtils.getTestType(cas, 1);
+    ai = cas.getAnnotationIndex(t);
+    assertEquals(1, ai.size());
+    iterator = ai.iterator();
+    assertEquals("Peter did", iterator.next().getCoveredText());
+    
+    if (cas != null) {
+      cas.release();
+    }
+
+  }
+  
 }