Merge branch 'master' into origin/bugfix/UIMA-6286-select-following-finds-zero-width-annotation-at-reference-end-position
* master: (134 commits)
[UIMA-6275] InitializableFactory is not smart enough to find a suitable classloader
No issue: ASF Jenkins Windows nodes seem to have trouble ('nohup' not found) - excluding Windows build nodes for the moment.
[UIMA-6270] Add selectOverlapping to (J)CasUtil
[UIMA-6270] Add selectOverlapping to (J)CasUtil
[UIMA-6263] CAS validation support
[UIMA-6264] Switch from DocBook to Asciidoc
[UIMA-6257] Jenkinsfile for uimaFIT
[UIMA-6257] Jenkinsfile for uimaFIT
[UIMA-6257] Jenkinsfile for uimaFIT
[UIMA-6257] Jenkinsfile for uimaFIT
[maven-release-plugin] prepare for next development iteration
[maven-release-plugin] prepare release uimafit-3.1.0
[maven-release-plugin] prepare for next development iteration
[maven-release-plugin] prepare release uimafit-3.1.0
[NO JIRA] Adjust UIMA version in the NOTICE file of the binary distribution
[maven-release-plugin] prepare for next development iteration
[maven-release-plugin] prepare release uimafit-3.1.0
[NO JIRA] Update documentation to changed API in ExternalResourceFactory and removed a spurious character
[NO JIRA] Adjusted comparison version for API change report
[NO JIRA] Updated README file for release.
...
% Conflicts:
% uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java b/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
index 187fe00..3e96190 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
@@ -1254,8 +1254,17 @@
}
// add annotations from the iterator into the result list
+ int refEnd = annotation.getEnd();
List<AnnotationFS> followingAnnotations = new ArrayList<AnnotationFS>();
for (int i = 0; i < count && itr.isValid(); i++, itr.moveToNext()) {
+ AnnotationFS fs = itr.get();
+ int begin = fs.getBegin();
+ int end = fs.getEnd();
+ if (begin == end && refEnd == begin) {
+ // Skip zero-width annotation at the end of the reference annotation. These are considered
+ // to be "coveredBy" instead of following
+ continue;
+ }
followingAnnotations.add(itr.get());
}
return followingAnnotations;
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/util/JCasUtilTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/util/JCasUtilTest.java
index 12290b6..1932ecd 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/util/JCasUtilTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/util/JCasUtilTest.java
@@ -21,6 +21,7 @@
*/
package org.apache.uima.fit.util;
+import static java.lang.Integer.MAX_VALUE;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import static org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription;
@@ -931,6 +932,34 @@
}
@Test
+ public void thatSelectFollowingDoesNotFindZeroWidthAnnotationAtEnd()
+ {
+ Annotation a1 = new Annotation(jCas, 10, 20);
+ Annotation a2 = new Annotation(jCas, 20, 20);
+
+ asList(a1, a2).forEach(a -> a.addToIndexes());
+
+ List<Annotation> selection = selectFollowing(Annotation.class, a1, MAX_VALUE);
+
+ assertThat(selection)
+ .isEmpty();
+ }
+
+ @Test
+ public void thatSelectPrecedingDoesNotFindZeroWidthAnnotationAtStart()
+ {
+ Annotation a1 = new Annotation(jCas, 10, 20);
+ Annotation a2 = new Annotation(jCas, 10, 10);
+
+ asList(a1, a2).forEach(a -> a.addToIndexes());
+
+ List<Annotation> selection = selectPreceding(Annotation.class, a1, MAX_VALUE);
+
+ assertThat(selection)
+ .isEmpty();
+ }
+
+ @Test
public void testExists() throws UIMAException {
JCas jcas = CasCreationUtils.createCas(createTypeSystemDescription(), null, null).getJCas();