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 2017/01/31 15:37:00 UTC
svn commit: r1781108 - in /uima/ruta/trunk:
ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
ruta-typesystem/src/main/java/org/apache/uima/ruta/type/RutaBasic.java
ruta-typesystem/src/main/java/org/apache/uima/ruta/type/RutaBasic_Type.java
Author: pkluegl
Date: Tue Jan 31 15:37:00 2017
New Revision: 1781108
URL: http://svn.apache.org/viewvc?rev=1781108&view=rev
Log:
no jira - fix license header, implement method
Modified:
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
uima/ruta/trunk/ruta-typesystem/src/main/java/org/apache/uima/ruta/type/RutaBasic.java
uima/ruta/trunk/ruta-typesystem/src/main/java/org/apache/uima/ruta/type/RutaBasic_Type.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=1781108&r1=1781107&r2=1781108&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 Tue Jan 31 15:37:00 2017
@@ -1292,9 +1292,40 @@ public class RutaStream extends FSIterat
}
public Type getSharedParentType(List<Type> types) {
+ if(types == null || types.isEmpty()) {
+ return cas.getAnnotationType();
+ }
+ if(types.size() == 1) {
+ return types.get(0);
+ }
TypeSystem typeSystem = cas.getTypeSystem();
- Type parentType = null;
- // TODO
- return types.get(0);
+ Type parentType = types.get(0);
+ for (Type type : types) {
+ parentType = getSharedParentType(parentType, type, typeSystem);
+ }
+ return parentType;
+ }
+
+ private Type getSharedParentType(Type type1, Type type2, TypeSystem typeSystem) {
+ if(cas.getAnnotationType().equals(type1) || cas.getAnnotationType().equals(type2)) {
+ return cas.getAnnotationType();
+ }
+ if(type1.equals(type2)) {
+ return type1;
+ }
+ if(typeSystem.subsumes(type1, type2)) {
+ return type1;
+ }
+ if(typeSystem.subsumes(type2, type1)) {
+ return type2;
+ }
+ Type parentType = typeSystem.getParent(type1);
+ while (parentType != null && !cas.getAnnotationType().equals(parentType)) {
+ if(typeSystem.subsumes(parentType, type2)) {
+ return parentType;
+ }
+ }
+
+ return cas.getAnnotationType();
}
}
Modified: uima/ruta/trunk/ruta-typesystem/src/main/java/org/apache/uima/ruta/type/RutaBasic.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-typesystem/src/main/java/org/apache/uima/ruta/type/RutaBasic.java?rev=1781108&r1=1781107&r2=1781108&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-typesystem/src/main/java/org/apache/uima/ruta/type/RutaBasic.java (original)
+++ uima/ruta/trunk/ruta-typesystem/src/main/java/org/apache/uima/ruta/type/RutaBasic.java Tue Jan 31 15:37:00 2017
@@ -1,4 +1,21 @@
-/* First created by JCasGen Wed Apr 16 17:01:16 CEST 2008 */
+/*
+ * 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.type;
import java.util.ArrayList;
Modified: uima/ruta/trunk/ruta-typesystem/src/main/java/org/apache/uima/ruta/type/RutaBasic_Type.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-typesystem/src/main/java/org/apache/uima/ruta/type/RutaBasic_Type.java?rev=1781108&r1=1781107&r2=1781108&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-typesystem/src/main/java/org/apache/uima/ruta/type/RutaBasic_Type.java (original)
+++ uima/ruta/trunk/ruta-typesystem/src/main/java/org/apache/uima/ruta/type/RutaBasic_Type.java Tue Jan 31 15:37:00 2017
@@ -1,4 +1,21 @@
-/* First created by JCasGen Tue Aug 09 16:26:13 CEST 2011 */
+/*
+ * 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.type;
import org.apache.uima.cas.Feature;