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/06/01 15:34:41 UTC
svn commit: r1488528 - in /uima/sandbox/ruta/trunk/ruta-core/src:
main/java/org/apache/uima/ruta/ main/java/org/apache/uima/ruta/rule/
test/java/org/apache/uima/ruta/ test/resources/org/apache/uima/ruta/
Author: pkluegl
Date: Sat Jun 1 13:34:41 2013
New Revision: 1488528
URL: http://svn.apache.org/r1488528
Log:
UIMA-2954
- fixed and added test
Added:
uima/sandbox/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/WildCardTest3.java
uima/sandbox/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/WildCardTest3.ruta
uima/sandbox/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/WildCardTest3.txt
Modified:
uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.java
Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java?rev=1488528&r1=1488527&r2=1488528&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java Sat Jun 1 13:34:41 2013
@@ -753,4 +753,12 @@ public class RutaStream extends FSIterat
}
}
+ public RutaBasic getAnchor(boolean direction, AnnotationFS annotation) {
+ if (direction) {
+ return getEndAnchor(annotation.getEnd());
+ } else {
+ return getBeginAnchor(annotation.getBegin());
+ }
+ }
+
}
Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.java?rev=1488528&r1=1488527&r2=1488528&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.java Sat Jun 1 13:34:41 2013
@@ -266,7 +266,7 @@ public class WildCardRuleElement extends
RutaTypeMatcher typeMatcher = (RutaTypeMatcher) re.getMatcher();
List<Type> types = typeMatcher.getTypes(parent, stream);
Type type = types.get(0);
- iterator = getIteratorOfType(type, annotation, stream);
+ iterator = getIteratorOfType(after, type, annotation, stream);
} else if (matcher instanceof RutaDisjunctiveMatcher) {
List<Type> types = matcher.getTypes(parent, stream);
iterator = getIteratorForDisjunctive(cas, types, after, annotation, stream);
@@ -274,7 +274,7 @@ public class WildCardRuleElement extends
// should not happen
}
} else {
- iterator = getIteratorOfType(defaultType, annotation, stream);
+ iterator = getIteratorOfType(after, defaultType, annotation, stream);
}
if (iterator.isValid() && iterator.get().equals(annotation)) {
moveOn(after, iterator);
@@ -282,7 +282,7 @@ public class WildCardRuleElement extends
return iterator;
}
- private FSIterator<AnnotationFS> getIteratorOfType(Type type, AnnotationFS annotation,
+ private FSIterator<AnnotationFS> getIteratorOfType(boolean after, Type type, AnnotationFS annotation,
RutaStream stream) {
CAS cas = stream.getCas();
FSIterator<AnnotationFS> result = null;
@@ -291,7 +291,8 @@ public class WildCardRuleElement extends
if (annotation == null) {
result = cas.getAnnotationIndex(type).iterator();
} else {
- result = cas.getAnnotationIndex(type).iterator(annotation);
+ AnnotationFS pointer = stream.getAnchor(after, annotation);
+ result = cas.getAnnotationIndex(type).iterator(pointer);
}
} else {
JCas jcas = null;
Added: uima/sandbox/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/WildCardTest3.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/WildCardTest3.java?rev=1488528&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/WildCardTest3.java (added)
+++ uima/sandbox/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/WildCardTest3.java Sat Jun 1 13:34:41 2013
@@ -0,0 +1,61 @@
+/*
+ * 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.RutaEngine;
+import org.junit.Test;
+
+public class WildCardTest3 {
+
+ @Test
+ public void test() {
+ String name = this.getClass().getSimpleName();
+ String namespace = this.getClass().getPackage().getName().replaceAll("\\.", "/");
+ CAS cas = null;
+ try {
+ cas = RutaTestUtils.process(namespace + "/" + name + RutaEngine.SCRIPT_FILE_EXTENSION, namespace + "/" + name
+ + ".txt", 50);
+ } catch (Exception e) {
+ e.printStackTrace();
+ assert (false);
+ }
+ Type t = null;
+ AnnotationIndex<AnnotationFS> ai = null;
+ FSIterator<AnnotationFS> iterator = null;
+
+ t = RutaTestUtils.getTestType(cas, 2);
+ ai = cas.getAnnotationIndex(t);
+ assertEquals(1, ai.size());
+ iterator = ai.iterator();
+ assertEquals("Peter Kluegl, Joern Kottmann, Marshall Schor,", iterator.next().getCoveredText());
+
+ if (cas != null) {
+ cas.release();
+ }
+
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/WildCardTest3.ruta
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/WildCardTest3.ruta?rev=1488528&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/WildCardTest3.ruta (added)
+++ uima/sandbox/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/WildCardTest3.ruta Sat Jun 1 13:34:41 2013
@@ -0,0 +1,10 @@
+PACKAGE uima.ruta.test;
+
+
+DECLARE T1, T2, T3, T4, T5, T6, T7, T8, T9,
+ T10, T11, T12, T13, T14, T15, T16, T17, T18, T19;
+
+(CW CW COMMA CW CW COMMA){-> T1};
+(T1 # COMMA){-> T2};
+
+
\ No newline at end of file
Added: uima/sandbox/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/WildCardTest3.txt
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/WildCardTest3.txt?rev=1488528&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/WildCardTest3.txt (added)
+++ uima/sandbox/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/WildCardTest3.txt Sat Jun 1 13:34:41 2013
@@ -0,0 +1 @@
+Peter Kluegl, Joern Kottmann, Marshall Schor, and others.
\ No newline at end of file