Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4150 - Upgrade dependencies #4287

Merged
merged 11 commits into from
Nov 7, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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;
Expand Down Expand Up @@ -100,40 +99,9 @@ protected boolean typeSystemInit(TypeSystem aTypeSystem)
@Override
public List<AnnotationFS> 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<AnnotationFS> list = new ArrayList<AnnotationFS>();

// withSnapshotIterators() not needed here since we copy the FSes to a list anyway
FSIterator<AnnotationFS> 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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,41 +71,9 @@ public SpanDiffAdapter(String aType, Set<String> aLabelFeatures)
@Override
public List<AnnotationFS> 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<AnnotationFS> list = new ArrayList<AnnotationFS>();

// withSnapshotIterators() not needed here since we copy the FSes to a list anyway
FSIterator<AnnotationFS> 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());
}

Expand Down
118 changes: 48 additions & 70 deletions inception/inception-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,10 @@
<dependencies>
<dependency>
<groupId>org.apache.uima</groupId>
<artifactId>uimaj-core</artifactId>
<version>${uima.version}</version>
</dependency>
<dependency>
<groupId>org.apache.uima</groupId>
<artifactId>uimaj-cpe</artifactId>
<version>${uima.version}</version>
</dependency>
<dependency>
<groupId>org.apache.uima</groupId>
<artifactId>uimaj-tools</artifactId>
<version>${uima.version}</version>
</dependency>
<dependency>
<groupId>org.apache.uima</groupId>
<artifactId>uimaj-json</artifactId>
<version>${uima.version}</version>
</dependency>
<dependency>
<groupId>org.apache.uima</groupId>
<artifactId>uimaj-document-annotation</artifactId>
<artifactId>uimaj-bom</artifactId>
<version>${uima.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.uima</groupId>
Expand All @@ -76,6 +58,49 @@
<version>${json.version}</version>
</dependency>

<!-- JAXB DEPENDENCIES -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-bom</artifactId>
<version>2.3.9</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.2.0</version>
<exclusions>
<exclusion>
<artifactId>dom4j</artifactId>
<groupId>dom4j</groupId>
</exclusion>
<exclusion>
<artifactId>xom</artifactId>
<groupId>xom</groupId>
</exclusion>
<exclusion>
<artifactId>jdom</artifactId>
<groupId>jdom</groupId>
</exclusion>
</exclusions>
</dependency>

<!-- Testing -->
<dependency>
<groupId>org.junit</groupId>
Expand Down Expand Up @@ -587,7 +612,7 @@
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>stax2-api</artifactId>
<version>4.2.1</version>
<version>4.2.2</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -974,53 +999,6 @@
<version>1.1.10.5</version>
</dependency>

<!-- JAXB DEPENDENCIES -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.8</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.8</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>1.2.0</version>
</dependency>

<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.2.0</version>
<exclusions>
<exclusion>
<artifactId>dom4j</artifactId>
<groupId>dom4j</groupId>
</exclusion>
<exclusion>
<artifactId>xom</artifactId>
<groupId>xom</groupId>
</exclusion>
<exclusion>
<artifactId>jdom</artifactId>
<groupId>jdom</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.dkpro.core</groupId>
<artifactId>dkpro-core-testing-asl</artifactId>
Expand Down Expand Up @@ -1081,7 +1059,7 @@
<dependency>
<groupId>com.github.jsonld-java</groupId>
<artifactId>jsonld-java</artifactId>
<version>0.13.4</version>
<version>0.13.6</version>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -77,19 +76,10 @@ public boolean check(Project aProject, CAS aCas, List<LogMessage> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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()));
}
}
Expand Down Expand Up @@ -136,9 +128,7 @@ private List<BioCSentence> processSentences(int aPassageOffset, List<Sentence> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -117,11 +116,8 @@ public static VModel visualModelFromCas(CAS cas, List<PdfPage> pdfPages)
VModel vModel;
List<VPage> vPages = new ArrayList<>();
for (PdfPage pdfPage : pdfPages) {
List<VChunk> vChunks = new ArrayList<>();
// https://github.com/apache/uima-uimaj/issues/345
// SelectFSs<PdfChunk> coveredBy = cas.select(PdfChunk.class).coveredBy(pdfPage);
List<PdfChunk> coveredBy = (List) CasUtil
.selectCovered(CasUtil.getType(cas, PdfChunk.class), pdfPage);
var vChunks = new ArrayList<VChunk>();
var coveredBy = cas.select(PdfChunk.class).coveredBy(pdfPage);
for (var pdfChunk : coveredBy) {
float d = pdfChunk.getD();
List<VGlyph> vGlyphs = new ArrayList<>();
Expand Down
Loading