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 2015/09/07 20:14:42 UTC
svn commit: r1701657 - in /uima/ruta/trunk/ruta-core/src:
main/java/org/apache/uima/ruta/ main/java/org/apache/uima/ruta/condition/
main/java/org/apache/uima/ruta/type/ test/java/org/apache/uima/ruta/
Author: pkluegl
Date: Mon Sep 7 18:14:42 2015
New Revision: 1701657
URL: http://svn.apache.org/r1701657
Log:
UIMA-4594
- added test
- added missing partof info for new ruta basic
- adapted PARTOF to its definition
Added:
uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/IncrementalPartitioningTest.java (with props)
Modified:
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfCondition.java
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/type/RutaBasic.java
Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java?rev=1701657&r1=1701656&r2=1701657&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java Mon Sep 7 18:14:42 2015
@@ -308,6 +308,7 @@ public class RutaStream extends FSIterat
RutaBasic newRB = new RutaBasic(getJCas(), anchor, newEnd);
newRB.setLowMemoryProfile(lowMemoryProfile);
newRB.setEndMap(toSplit.getEndMap());
+ newRB.setPartOf(toSplit.getPartOf());
toSplit.clearEndMap();
cas.addFsToIndexes(toSplit);
cas.addFsToIndexes(newRB);
Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfCondition.java?rev=1701657&r1=1701656&r2=1701657&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfCondition.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfCondition.java Mon Sep 7 18:14:42 2015
@@ -64,8 +64,23 @@ public class PartOfCondition extends Typ
private boolean check(Type t, AnnotationFS annotation, RuleElement element, RutaStream stream) {
RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());
+ if(beginAnchor!= null && beginAnchor.isPartOf(t)) {
+ return true;
+ }
+ RutaBasic endAnchor = stream.getEndAnchor(annotation.getEnd());
+ if(endAnchor!= null && endAnchor.isPartOf(t)) {
+ return true;
+ }
+ // TODO: do we really need to check again on the anchors?
Collection<AnnotationFS> beginAnchors = beginAnchor.getBeginAnchors(t);
- return beginAnchor.isPartOf(t) || (beginAnchors != null && !beginAnchors.isEmpty());
+ if(beginAnchors != null && !beginAnchors.isEmpty()) {
+ return true;
+ }
+ Collection<AnnotationFS> endAnchors = beginAnchor.getEndAnchors(t);
+ if(endAnchors != null && !endAnchors.isEmpty()) {
+ return true;
+ }
+ return false;
}
}
Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/type/RutaBasic.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/type/RutaBasic.java?rev=1701657&r1=1701656&r2=1701657&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/type/RutaBasic.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/type/RutaBasic.java Mon Sep 7 18:14:42 2015
@@ -108,6 +108,14 @@ public class RutaBasic extends Annotatio
}
+ public void setPartOf(int[] partOf) {
+ this.partOf = partOf;
+ }
+
+ public int[] getPartOf() {
+ return partOf;
+ }
+
@SuppressWarnings("unchecked")
public Collection<AnnotationFS> getBeginAnchors(Type type) {
int code = ((TypeImpl) type).getCode();
Added: uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/IncrementalPartitioningTest.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/IncrementalPartitioningTest.java?rev=1701657&view=auto
==============================================================================
--- uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/IncrementalPartitioningTest.java (added)
+++ uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/IncrementalPartitioningTest.java Mon Sep 7 18:14:42 2015
@@ -0,0 +1,53 @@
+/*
+ * 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 org.apache.uima.cas.CAS;
+import org.apache.uima.ruta.engine.Ruta;
+import org.apache.uima.ruta.engine.RutaTestUtils;
+import org.junit.Test;
+
+public class IncrementalPartitioningTest {
+
+ @Test
+ public void test() {
+ String document = "fünfundzwanzig";
+ String script = "";
+ script += "\"fünf\"->T1;";
+ script += "\"und\"->T2;";
+ script += "\"zwanzig\"->T1;";
+ script += "T1{PARTOF(W)-> T4};";
+
+ CAS cas = null;
+ try {
+ cas = RutaTestUtils.getCAS(document);
+ Ruta.apply(cas, script);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ RutaTestUtils.assertAnnotationsEquals(cas, 4, 2, "fünf", "zwanzig");
+
+ if (cas != null) {
+ cas.release();
+ }
+
+ }
+}
Propchange: uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/IncrementalPartitioningTest.java
------------------------------------------------------------------------------
svn:eol-style = native