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/02/27 15:27:55 UTC

svn commit: r1572590 - in /uima/ruta/trunk/ruta-core/src: main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java main/java/org/apache/uima/ruta/rule/RutaRuleElement.java test/java/org/apache/uima/ruta/NestedDisjunctiveTest.java

Author: pkluegl
Date: Thu Feb 27 14:27:54 2014
New Revision: 1572590

URL: http://svn.apache.org/r1572590
Log:
UIMA-3656
- fixed missing entry points
- added test

Added:
    uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/NestedDisjunctiveTest.java   (with props)
Modified:
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java?rev=1572590&r1=1572589&r2=1572590&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java Thu Feb 27 14:27:54 2014
@@ -393,13 +393,13 @@ public class ComposedRuleElement extends
         // TODO failed was caused by a child: should here failed = false?
         if (!removedFailedMatches && evaluateMatches != null && continueMatch) {
           result = continueOwnMatch(after, annotation, ruleMatch, ruleApply, parentContainerMatch,
-                  sideStepOrigin, null, stream, crowd);
+                  sideStepOrigin, entryPoint, stream, crowd);
         } else if (nextElement != null) {
           AnnotationFS backtrackedAnnotation = getBacktrackedAnnotation(after, evaluateMatches,
                   annotation);
           if (backtrackedAnnotation != null) {
             result = nextElement.continueMatch(after, backtrackedAnnotation, ruleMatch, ruleApply,
-                    parentContainerMatch, sideStepOrigin, null, stream, crowd);
+                    parentContainerMatch, sideStepOrigin, entryPoint, stream, crowd);
           } else {
             result = fallback(after, failed, annotation, ruleMatch, ruleApply,
                     parentContainerMatch, sideStepOrigin, entryPoint, stream, crowd);
@@ -414,7 +414,7 @@ public class ComposedRuleElement extends
                   sideStepOrigin, null, stream, crowd);
         } else if (nextElement != null) {
           result = nextElement.continueMatch(after, annotation, ruleMatch, ruleApply,
-                  parentContainerMatch, sideStepOrigin, null, stream, crowd);
+                  parentContainerMatch, sideStepOrigin, entryPoint, stream, crowd);
         } else {
           result = fallback(after, failed, annotation, ruleMatch, ruleApply, parentContainerMatch,
                   sideStepOrigin, entryPoint, stream, crowd);

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java?rev=1572590&r1=1572589&r2=1572590&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java Thu Feb 27 14:27:54 2014
@@ -78,7 +78,7 @@ public class RutaRuleElement extends Abs
         if (quantifier.continueMatch(true, eachAnchor, this, extendedMatch, extendedContainerMatch,
                 stream, crowd)) {
           List<RuleMatch> continueOwnMatch = continueOwnMatch(true, eachAnchor, extendedMatch,
-                  ruleApply, extendedContainerMatch, sideStepOrigin, null, stream, crowd);
+                  ruleApply, extendedContainerMatch, sideStepOrigin, entryPoint, stream, crowd);
           result.addAll(continueOwnMatch);
         } else {
           if (after != null) {
@@ -270,7 +270,7 @@ public class RutaRuleElement extends Abs
           RutaRuleElement sideStepOrigin, RutaStream stream, InferenceCrowd crowd,
           RuleElement entryPoint) {
     List<RuleMatch> result = new ArrayList<RuleMatch>();
-    if (ruleApply == null) {
+    if (this.equals(entryPoint) && ruleApply == null) {
       result.add(ruleMatch);
       return result;
     }
@@ -299,7 +299,7 @@ public class RutaRuleElement extends Abs
       ruleMatch.setMatched(evaluateMatches != null);
       if (ruleMatch.matched()) {
         result = continueMatchSomewhereElse(after, false, annotation, ruleMatch, ruleApply,
-                containerMatch, sideStepOrigin, null, stream, crowd);
+                containerMatch, sideStepOrigin, entryPoint, stream, crowd);
       } else {
         if (getContainer() instanceof ComposedRuleElement) {
           ComposedRuleElement composed = (ComposedRuleElement) getContainer();

Added: uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/NestedDisjunctiveTest.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/NestedDisjunctiveTest.java?rev=1572590&view=auto
==============================================================================
--- uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/NestedDisjunctiveTest.java (added)
+++ uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/NestedDisjunctiveTest.java Thu Feb 27 14:27:54 2014
@@ -0,0 +1,69 @@
+/*
+ * 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 static org.junit.Assert.assertEquals;
+
+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.ruta.engine.Ruta;
+import org.junit.Test;
+
+public class NestedDisjunctiveTest {
+
+  @Test
+  public void test() {
+    String document = "";
+    document +=
+    "A: C D X\n";
+    document +="B C D X\n";
+    document +="E X\n";
+    document +="F X\n";
+    String script = "(((\"A\" | \"B\") COLON? \"C\" \"D\") | (\"E\" | \"F\")) ANY {->MARK(T1)};";
+    CAS cas = null;
+    try {
+      cas = RutaTestUtils.getCAS(document);
+      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(4, ai.size());
+    iterator = ai.iterator();
+    assertEquals("X", iterator.next().getCoveredText());
+    assertEquals("X", iterator.next().getCoveredText());
+    assertEquals("X", iterator.next().getCoveredText());
+    assertEquals("X", iterator.next().getCoveredText());
+
+    if (cas != null) {
+      cas.release();
+    }
+
+  }
+}

Propchange: uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/NestedDisjunctiveTest.java
------------------------------------------------------------------------------
    svn:eol-style = native