Hi,
I am migrating some code to the new UIMA v3 select API, and I am seeing some
odd behaviour. My reference implementation is the good old
JCasUtil.selectCovered, which I am trying to replace first, and I thought the
following line should do it:
jCas.select(annotationType).coveredBy(annotation)
This works fine as long annotation is of annotationType, but I am seeing some
strange different output when annotation is of a different Annotation subtype.
More specifically I have a unit test (see bottom) where annotationType is the
Annotation class and annotation is an instance of some direct subtype of
Annotation, which was added to the CAS index prior to the call. In this case
all annotations that have the exact same bounds as annotation are not selected,
only those that are completely enclosed get selected (begin >
annotation.getBegin() and end < annotation.getEnd()). The JCasUtil includes the
missing annotations.
None of the available select configurations seem to address this, and
superficially stepping through the code didn’t help me much, since it’s not
trivial to get into the details of the underlying API, so I thought that I
maybe get a faster answer here.
Cheers
Mario
@Test
public void verify_selectCovered() throws CASException,
ResourceInitializationException {
JCas jCas = JCasFactory.createJCas();
Annotation[] fixture = new Annotation[] {
new Annotation(jCas, 5, 10),
new Annotation(jCas, 5, 15),
new Annotation(jCas, 0, 10),
new Annotation(jCas, 0, 15),
new Annotation(jCas, 5, 7),
new Annotation(jCas, 8, 10),
new Annotation(jCas, 6, 9),
new Annotation(jCas, 5, 10)
};
Stream.of(fixture).forEach(Annotation::addToIndexes);
assertEquals(4, JCasUtil.selectCovered(jCas, Annotation.class,
fixture[0]).size());
List<Annotation> selection1 = jCas.select(Annotation.class)
.coveredBy(fixture[0])
.collect(Collectors.toList());
assertEquals(4, selection1.size());
SubType subType = new SubType(jCas, 5, 10);
subType.addToIndexes();
assertEquals(5, JCasUtil.selectCovered(jCas, Annotation.class,
subType).size());
List<Annotation> selection2 = jCas.select(Annotation.class)
.coveredBy(subType)
.collect(Collectors.toList());
assertEquals(5, selection2.size()); // Fails!
}
________________________________
Disclaimer:
This email and any files transmitted with it are confidential and directed
solely for the use of the intended addressee or addressees and may contain
information that is legally privileged, confidential, and exempt from
disclosure. If you have received this email in error, please notify the sender
by telephone, fax, or return email and immediately delete this email and any
files transmitted along with it. Unintended recipients are not authorized to
disclose, disseminate, distribute, copy or take any action in reliance on
information contained in this email and/or any files attached thereto, in any
manner other than to notify the sender; any unauthorized use is subject to
legal prosecution.