diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanRenderer.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanRenderer.java index 0aa9c4dba39..050b2d41c57 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanRenderer.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanRenderer.java @@ -30,7 +30,6 @@ import java.util.Optional; import org.apache.uima.cas.CAS; -import org.apache.uima.cas.FSIterator; import org.apache.uima.cas.FeatureStructure; import org.apache.uima.cas.Type; import org.apache.uima.cas.TypeSystem; @@ -93,40 +92,9 @@ protected boolean typeSystemInit(TypeSystem aTypeSystem) @Override public List selectAnnotationsInWindow(CAS aCas, int aWindowBegin, int aWindowEnd) { - // https://github.com/apache/uima-uimaj/issues/345 - // return aCas.select(type).coveredBy(0, aWindowEnd).includeAnnotationsWithEndBeyondBounds() - // .map(fs -> (AnnotationFS) fs) - // .filter(ann -> AnnotationPredicates.overlapping(ann, aWindowBegin, aWindowEnd)) - // .collect(toList()); - - List list = new ArrayList(); - - // withSnapshotIterators() not needed here since we copy the FSes to a list anyway - FSIterator it = aCas.getAnnotationIndex(type).iterator(); - - // Skip annotations whose start is before the start parameter. - while (it.isValid() && (it.get()).getBegin() < 0) { - it.moveToNext(); - } - - boolean strict = false; - while (it.isValid()) { - AnnotationFS a = it.get(); - // If the start of the current annotation is past the end parameter, we're done. - if (a.getBegin() > aWindowEnd) { - break; - } - it.moveToNext(); - if (strict && a.getEnd() > aWindowEnd) { - continue; - } - - list.add(a); - } - - return list.stream() // - .map(fs -> (AnnotationFS) fs) // - .filter(ann -> AnnotationPredicates.overlapping(ann, aWindowBegin, aWindowEnd)) // + return aCas.select(type).coveredBy(0, aWindowEnd).includeAnnotationsWithEndBeyondBounds() + .map(fs -> (AnnotationFS) fs) + .filter(ann -> AnnotationPredicates.overlapping(ann, aWindowBegin, aWindowEnd)) .collect(toList()); } diff --git a/inception/inception-curation-legacy/src/main/java/de/tudarmstadt/ukp/clarin/webanno/curation/casdiff/span/SpanDiffAdapter.java b/inception/inception-curation-legacy/src/main/java/de/tudarmstadt/ukp/clarin/webanno/curation/casdiff/span/SpanDiffAdapter.java index e17a522228e..4ad640c22bc 100644 --- a/inception/inception-curation-legacy/src/main/java/de/tudarmstadt/ukp/clarin/webanno/curation/casdiff/span/SpanDiffAdapter.java +++ b/inception/inception-curation-legacy/src/main/java/de/tudarmstadt/ukp/clarin/webanno/curation/casdiff/span/SpanDiffAdapter.java @@ -20,17 +20,14 @@ import static java.util.Arrays.asList; import static java.util.stream.Collectors.toList; -import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import org.apache.uima.cas.CAS; -import org.apache.uima.cas.FSIterator; import org.apache.uima.cas.FeatureStructure; import org.apache.uima.cas.text.AnnotationFS; import org.apache.uima.cas.text.AnnotationPredicates; -import org.apache.uima.fit.util.CasUtil; import org.apache.uima.fit.util.FSUtil; import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; @@ -74,41 +71,9 @@ public SpanDiffAdapter(String aType, Set aLabelFeatures) @Override public List selectAnnotationsInWindow(CAS aCas, int aWindowBegin, int aWindowEnd) { - // https://github.com/apache/uima-uimaj/issues/345 - // return aCas.select(type).coveredBy(0, aWindowEnd).includeAnnotationsWithEndBeyondBounds() - // .map(fs -> (AnnotationFS) fs) - // .filter(ann -> AnnotationPredicates.overlapping(ann, aWindowBegin, aWindowEnd)) - // .collect(toList()); - - List list = new ArrayList(); - - // withSnapshotIterators() not needed here since we copy the FSes to a list anyway - FSIterator it = aCas.getAnnotationIndex(CasUtil.getType(aCas, getType())) - .iterator(); - - // Skip annotations whose start is before the start parameter. - while (it.isValid() && (it.get()).getBegin() < aWindowBegin) { - it.moveToNext(); - } - - boolean strict = false; - while (it.isValid()) { - AnnotationFS a = it.get(); - // If the start of the current annotation is past the end parameter, we're done. - if (a.getBegin() > aWindowEnd) { - break; - } - it.moveToNext(); - if (strict && a.getEnd() > aWindowEnd) { - continue; - } - - list.add(a); - } - - return list.stream() // - .map(fs -> (AnnotationFS) fs) // - .filter(ann -> AnnotationPredicates.overlapping(ann, aWindowBegin, aWindowEnd)) // + return aCas.select(getType()).coveredBy(0, aWindowEnd) + .includeAnnotationsWithEndBeyondBounds().map(fs -> (AnnotationFS) fs) + .filter(ann -> AnnotationPredicates.overlapping(ann, aWindowBegin, aWindowEnd)) .collect(toList()); } diff --git a/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/AllAnnotationsStartAndEndWithinSentencesCheck.java b/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/AllAnnotationsStartAndEndWithinSentencesCheck.java index d68d344e0cf..f17ba3e1434 100644 --- a/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/AllAnnotationsStartAndEndWithinSentencesCheck.java +++ b/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/AllAnnotationsStartAndEndWithinSentencesCheck.java @@ -27,7 +27,6 @@ import org.apache.uima.cas.CAS; import org.apache.uima.cas.Type; import org.apache.uima.cas.text.AnnotationFS; -import org.apache.uima.fit.util.CasUtil; import org.springframework.util.CollectionUtils; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer; @@ -77,19 +76,10 @@ public boolean check(Project aProject, CAS aCas, List aMessages) } for (AnnotationFS ann : select(aCas, type)) { - // https://github.com/apache/uima-uimaj/issues/345 - // var startsOutside = aCas.select(Sentence._TypeName) - // .covering(ann.getBegin(), ann.getBegin()).isEmpty(); - var startsOutside = CasUtil - .selectCovering(ann.getCAS(), CasUtil.getType(ann.getCAS(), Sentence.class), - ann.getBegin(), ann.getBegin()) - .isEmpty(); - // https://github.com/apache/uima-uimaj/issues/345 - // var endsOutside = aCas.select(Sentence._TypeName) - // .covering(ann.getEnd(), ann.getEnd()).isEmpty(); - var endsOutside = CasUtil.selectCovering(ann.getCAS(), - CasUtil.getType(ann.getCAS(), Sentence.class), ann.getEnd(), ann.getEnd()) - .isEmpty(); + var startsOutside = aCas.select(Sentence._TypeName) + .covering(ann.getBegin(), ann.getBegin()).isEmpty(); + var endsOutside = aCas.select(Sentence._TypeName) + .covering(ann.getEnd(), ann.getEnd()).isEmpty(); if (!startsOutside && !endsOutside) { continue; diff --git a/inception/inception-io-bioc/src/main/java/de/tudarmstadt/ukp/inception/io/bioc/model/CasToBioC.java b/inception/inception-io-bioc/src/main/java/de/tudarmstadt/ukp/inception/io/bioc/model/CasToBioC.java index 8e389b28220..d61aa34634c 100644 --- a/inception/inception-io-bioc/src/main/java/de/tudarmstadt/ukp/inception/io/bioc/model/CasToBioC.java +++ b/inception/inception-io-bioc/src/main/java/de/tudarmstadt/ukp/inception/io/bioc/model/CasToBioC.java @@ -40,7 +40,6 @@ import org.apache.uima.cas.text.AnnotationFS; import org.apache.uima.fit.util.FSUtil; -import org.apache.uima.fit.util.JCasUtil; import org.apache.uima.jcas.JCas; import org.apache.uima.jcas.tcas.Annotation; import org.dkpro.core.api.xml.type.XmlElement; @@ -82,12 +81,8 @@ public void convert(JCas aJCas, BioCCollection aCollection) bioCPassage.addInfon(I_TYPE, div.getDivType()); } - // https://github.com/apache/uima-uimaj/issues/345 - // var sentences = aJCas.select(Sentence.class).coveredBy(div).asList(); - var sentences = JCasUtil.selectCovered(Sentence.class, div); - // https://github.com/apache/uima-uimaj/issues/345 - // var annotations = aJCas.select(Annotation.class).coveredBy(div); - var annotations = JCasUtil.selectCovered(Annotation.class, div); + var sentences = aJCas.select(Sentence.class).coveredBy(div).asList(); + var annotations = aJCas.select(Annotation.class).coveredBy(div); if (sentences.isEmpty()) { bioCPassage.setText(div.getCoveredText()); processAnnotations(bioCPassage, bioCPassage.getOffset(), annotations); @@ -96,10 +91,7 @@ public void convert(JCas aJCas, BioCCollection aCollection) var bioCSentences = processSentences(div.getBegin(), sentences); bioCPassage.setSentences(bioCSentences); processAnnotations(bioCPassage, bioCPassage.getOffset(), - annotations.stream().filter(a -> - // https://github.com/apache/uima-uimaj/issues/345 - // aJCas.select(Sentence.class).covering(a).isEmpty() - JCasUtil.selectCovering(Sentence.class, a).isEmpty()) + annotations.filter(a -> aJCas.select(Sentence.class).covering(a).isEmpty()) .collect(Collectors.toList())); } } @@ -136,9 +128,7 @@ private List processSentences(int aPassageOffset, List s bioCSentence.setText(sentence.getCoveredText()); processAnnotations(bioCSentence, sentence.getBegin(), - // https://github.com/apache/uima-uimaj/issues/345 - // sentence.getCAS().select(Annotation.class).coveredBy(sentence) - JCasUtil.selectCovered(Annotation.class, sentence)); + sentence.getCAS().select(Annotation.class).coveredBy(sentence)); bioCSentences.add(bioCSentence); } diff --git a/inception/inception-io-bioc/src/main/java/de/tudarmstadt/ukp/inception/io/bioc/xml/Cas2BioCSaxEvents.java b/inception/inception-io-bioc/src/main/java/de/tudarmstadt/ukp/inception/io/bioc/xml/Cas2BioCSaxEvents.java index d2a7351539c..31854625b8d 100644 --- a/inception/inception-io-bioc/src/main/java/de/tudarmstadt/ukp/inception/io/bioc/xml/Cas2BioCSaxEvents.java +++ b/inception/inception-io-bioc/src/main/java/de/tudarmstadt/ukp/inception/io/bioc/xml/Cas2BioCSaxEvents.java @@ -58,7 +58,6 @@ import org.apache.uima.cas.CAS; import org.apache.uima.cas.text.AnnotationFS; import org.apache.uima.fit.util.FSUtil; -import org.apache.uima.fit.util.JCasUtil; import org.apache.uima.jcas.JCas; import org.apache.uima.jcas.tcas.Annotation; import org.dkpro.core.api.xml.type.XmlElement; @@ -140,10 +139,8 @@ private void processSentenceElement(XmlElement aSentenceElement) throws SAXExcep return; } - // https://github.com/apache/uima-uimaj/issues/345 - // var annotations = aSentenceElement.getCAS().select(Annotation.class) - // .coveredBy(aSentenceElement); - var annotations = JCasUtil.selectCovered(Annotation.class, aSentenceElement); + var annotations = aSentenceElement.getCAS().select(Annotation.class) + .coveredBy(aSentenceElement); for (var annotation : annotations) { serializeAnnotation(sentenceTextElement.get().getBegin(), annotation); } diff --git a/inception/inception-pdf-editor2/src/main/java/de/tudarmstadt/ukp/inception/pdfeditor2/format/VisualPdfReader.java b/inception/inception-pdf-editor2/src/main/java/de/tudarmstadt/ukp/inception/pdfeditor2/format/VisualPdfReader.java index 318683c6fa1..b661be7b457 100644 --- a/inception/inception-pdf-editor2/src/main/java/de/tudarmstadt/ukp/inception/pdfeditor2/format/VisualPdfReader.java +++ b/inception/inception-pdf-editor2/src/main/java/de/tudarmstadt/ukp/inception/pdfeditor2/format/VisualPdfReader.java @@ -27,7 +27,6 @@ import org.apache.uima.cas.CAS; import org.apache.uima.collection.CollectionException; import org.apache.uima.fit.descriptor.ConfigurationParameter; -import org.apache.uima.fit.util.CasUtil; import org.apache.uima.jcas.JCas; import org.apache.uima.jcas.cas.FloatArray; import org.apache.uima.jcas.cas.IntegerArray; @@ -117,11 +116,8 @@ public static VModel visualModelFromCas(CAS cas, List pdfPages) VModel vModel; List vPages = new ArrayList<>(); for (PdfPage pdfPage : pdfPages) { - List vChunks = new ArrayList<>(); - // https://github.com/apache/uima-uimaj/issues/345 - // SelectFSs coveredBy = cas.select(PdfChunk.class).coveredBy(pdfPage); - List coveredBy = (List) CasUtil - .selectCovered(CasUtil.getType(cas, PdfChunk.class), pdfPage); + var vChunks = new ArrayList(); + var coveredBy = cas.select(PdfChunk.class).coveredBy(pdfPage); for (var pdfChunk : coveredBy) { float d = pdfChunk.getD(); List vGlyphs = new ArrayList<>(); diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/service/RecommendationServiceImpl.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/service/RecommendationServiceImpl.java index 7d6ba5421c2..fa7e72568d6 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/service/RecommendationServiceImpl.java +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/service/RecommendationServiceImpl.java @@ -1081,12 +1081,9 @@ private AnnotationFS acceptOrCorrectSuggestion(String aSessionOwner, SourceDocum var aEnd = aSuggestion.getEnd(); var aValue = aSuggestion.getLabel(); - // https://github.com/apache/uima-uimaj/issues/345 - // var candidates = aCas. select(aAdapter.getAnnotationTypeName()) // - // .at(aBegin, aEnd) // - // .asList(); - var candidates = CasUtil.selectAt(aCas, - CasUtil.getType(aCas, aAdapter.getAnnotationTypeName()), aBegin, aEnd); + var candidates = aCas. select(aAdapter.getAnnotationTypeName()) // + .at(aBegin, aEnd) // + .asList(); var candidateWithEmptyLabel = candidates.stream() // .filter(c -> aAdapter.getFeatureValue(aFeature, c) == null) // @@ -2087,15 +2084,9 @@ private static Optional getOffsetsAnchoredOnSingleTokens(CAS aOriginalCa Annotation aPredictedAnnotation) { Type tokenType = getType(aOriginalCas, Token.class); - // https://github.com/apache/uima-uimaj/issues/345 - // var tokens = aOriginalCas. select(tokenType) // - // .coveredBy(aPredictedAnnotation) // - // .limit(2).asList(); - var tokens = CasUtil - .selectCovered(aOriginalCas, tokenType, aPredictedAnnotation.getBegin(), - aPredictedAnnotation.getEnd()) - .stream() // - .limit(2).collect(toList()); + var tokens = aOriginalCas. select(tokenType) // + .coveredBy(aPredictedAnnotation) // + .limit(2).asList(); if (tokens.isEmpty()) { // This can happen if a recommender uses different token boundaries (e.g. if a @@ -2122,13 +2113,9 @@ private static Optional getOffsetsAnchoredOnSingleTokens(CAS aOriginalCa private static Optional getOffsetsAnchoredOnSentences(CAS aOriginalCas, Annotation aPredictedAnnotation) { - // https://github.com/apache/uima-uimaj/issues/345 - // var sentences = aOriginalCas.select(Sentence.class) // - // .coveredBy(aPredictedAnnotation) // - // .asList(); - var sentences = CasUtil.selectCovered(aOriginalCas, - CasUtil.getType(aOriginalCas, Sentence.class), aPredictedAnnotation.getBegin(), - aPredictedAnnotation.getEnd()); + var sentences = aOriginalCas.select(Sentence.class) // + .coveredBy(aPredictedAnnotation) // + .asList(); if (sentences.isEmpty()) { // This can happen if a recommender uses different token boundaries (e.g. if a @@ -2147,12 +2134,9 @@ private static Optional getOffsetsAnchoredOnSentences(CAS aOriginalCas, static Optional getOffsetsAnchoredOnTokens(CAS aOriginalCas, Annotation aPredictedAnnotation) { - // https://github.com/apache/uima-uimaj/issues/345 - // var tokens = aOriginalCas.select(Token.class) // - // .coveredBy(aPredictedAnnotation) // - // .asList(); - var tokens = CasUtil.selectCovered(aOriginalCas, CasUtil.getType(aOriginalCas, Token.class), - aPredictedAnnotation.getBegin(), aPredictedAnnotation.getEnd()); + var tokens = aOriginalCas.select(Token.class) // + .coveredBy(aPredictedAnnotation) // + .asList(); if (tokens.isEmpty()) { if (aPredictedAnnotation.getBegin() == aPredictedAnnotation.getEnd()) { diff --git a/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/detail/AnnotationDetailEditorPanel.java b/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/detail/AnnotationDetailEditorPanel.java index 5c6344ed73b..be0a6215088 100644 --- a/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/detail/AnnotationDetailEditorPanel.java +++ b/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/detail/AnnotationDetailEditorPanel.java @@ -1235,15 +1235,8 @@ public void onBulkAnnotationEvent(BulkAnnotationEvent aEvent) try { var selection = getModelObject().getSelection(); int id = selection.getAnnotation().getId(); - // https://github.com/apache/uima-uimaj/issues/345 - // boolean annotationStillExists = getEditorCas().select(Annotation.class) // - // .at(selection.getBegin(), selection.getEnd()) // - // .anyMatch(ann -> ann._id() == id); - var cas = getEditorCas(); - boolean annotationStillExists = CasUtil - .selectAt(cas, CasUtil.getType(cas, Annotation.class), selection.getBegin(), - selection.getEnd()) - .stream() // + boolean annotationStillExists = getEditorCas().select(Annotation.class) // + .at(selection.getBegin(), selection.getEnd()) // .anyMatch(ann -> ann._id() == id); if (!annotationStillExists) {