diff --git a/inception/inception-agreement/src/main/java/de/tudarmstadt/ukp/clarin/webanno/agreement/AgreementUtils.java b/inception/inception-agreement/src/main/java/de/tudarmstadt/ukp/clarin/webanno/agreement/AgreementUtils.java index 261363d55ea..8727d8e51cc 100644 --- a/inception/inception-agreement/src/main/java/de/tudarmstadt/ukp/clarin/webanno/agreement/AgreementUtils.java +++ b/inception/inception-agreement/src/main/java/de/tudarmstadt/ukp/clarin/webanno/agreement/AgreementUtils.java @@ -17,7 +17,7 @@ */ package de.tudarmstadt.ukp.clarin.webanno.agreement; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getFeature; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.getFeature; import static java.util.Arrays.asList; import java.io.ByteArrayInputStream; diff --git a/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/CasStorageServiceImpl.java b/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/CasStorageServiceImpl.java index f7dfdcbc6be..9099169c90f 100644 --- a/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/CasStorageServiceImpl.java +++ b/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/CasStorageServiceImpl.java @@ -17,8 +17,6 @@ */ package de.tudarmstadt.ukp.inception.annotation.storage; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getRealCas; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.transferCasOwnershipToCurrentThread; import static de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasAccessMode.EXCLUSIVE_WRITE_ACCESS; import static de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasAccessMode.SHARED_READ_ONLY_ACCESS; import static de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasAccessMode.UNMANAGED_ACCESS; @@ -27,6 +25,8 @@ import static de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasUpgradeMode.NO_CAS_UPGRADE; import static de.tudarmstadt.ukp.inception.annotation.storage.CasStorageServiceImpl.RepairAndUpgradeFlags.ISOLATED_SESSION; import static de.tudarmstadt.ukp.inception.project.api.ProjectService.withProjectLogger; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.getRealCas; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.transferCasOwnershipToCurrentThread; import static java.lang.System.currentTimeMillis; import static java.util.Collections.newSetFromMap; import static java.util.Collections.synchronizedSet; diff --git a/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/CasStorageSession.java b/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/CasStorageSession.java index c19414810f3..c1c78b7d4f1 100644 --- a/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/CasStorageSession.java +++ b/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/CasStorageSession.java @@ -31,12 +31,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasAccessMode; import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasSessionException; import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasStorageService; import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.WriteAccessNotPermittedException; import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; public class CasStorageSession implements AutoCloseable diff --git a/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/driver/filesystem/CasPersistenceUtils.java b/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/driver/filesystem/CasPersistenceUtils.java index 06eb3bde93a..8a2c115adb4 100644 --- a/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/driver/filesystem/CasPersistenceUtils.java +++ b/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/driver/filesystem/CasPersistenceUtils.java @@ -17,7 +17,7 @@ */ package de.tudarmstadt.ukp.inception.annotation.storage.driver.filesystem; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getRealCas; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.getRealCas; import static java.io.ObjectInputFilter.Config.createFilter; import static java.lang.String.join; import static org.apache.uima.cas.SerialFormat.XMI; @@ -51,8 +51,8 @@ import org.xerial.snappy.SnappyFramedInputStream; import org.xerial.snappy.SnappyFramedOutputStream; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; public final class CasPersistenceUtils { diff --git a/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/driver/filesystem/FileSystemCasStorageDriver.java b/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/driver/filesystem/FileSystemCasStorageDriver.java index 9b2bee65c34..b24d668a9bf 100644 --- a/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/driver/filesystem/FileSystemCasStorageDriver.java +++ b/inception/inception-annotation-storage/src/main/java/de/tudarmstadt/ukp/inception/annotation/storage/driver/filesystem/FileSystemCasStorageDriver.java @@ -17,11 +17,11 @@ */ package de.tudarmstadt.ukp.inception.annotation.storage.driver.filesystem; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.setDocumentId; import static de.tudarmstadt.ukp.inception.project.api.ProjectService.ANNOTATION_FOLDER; import static de.tudarmstadt.ukp.inception.project.api.ProjectService.DOCUMENT_FOLDER; import static de.tudarmstadt.ukp.inception.project.api.ProjectService.PROJECT_FOLDER; import static de.tudarmstadt.ukp.inception.support.logging.BaseLoggers.BOOT_LOG; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.setDocumentId; import static java.lang.System.currentTimeMillis; import static java.nio.file.Files.move; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; @@ -56,7 +56,6 @@ import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.LoadingCache; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.ConcurentCasModificationException; import de.tudarmstadt.ukp.clarin.webanno.api.type.CASMetadata; import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument; @@ -66,6 +65,7 @@ import de.tudarmstadt.ukp.inception.annotation.storage.config.CasStorageProperties; import de.tudarmstadt.ukp.inception.annotation.storage.driver.CasStorageDriver; import de.tudarmstadt.ukp.inception.documents.api.RepositoryProperties; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; import de.tudarmstadt.ukp.inception.support.wicket.WicketUtil; public class FileSystemCasStorageDriver diff --git a/inception/inception-annotation-storage/src/test/java/de/tudarmstadt/ukp/inception/annotation/storage/CasStorageServiceImplTest.java b/inception/inception-annotation-storage/src/test/java/de/tudarmstadt/ukp/inception/annotation/storage/CasStorageServiceImplTest.java index c67347c8431..9e193252cd3 100644 --- a/inception/inception-annotation-storage/src/test/java/de/tudarmstadt/ukp/inception/annotation/storage/CasStorageServiceImplTest.java +++ b/inception/inception-annotation-storage/src/test/java/de/tudarmstadt/ukp/inception/annotation/storage/CasStorageServiceImplTest.java @@ -59,7 +59,6 @@ import org.slf4j.LoggerFactory; import org.slf4j.MDC; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasProvider; import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasSessionException; import de.tudarmstadt.ukp.clarin.webanno.api.type.CASMetadata; @@ -72,6 +71,7 @@ import de.tudarmstadt.ukp.inception.documents.api.RepositoryProperties; import de.tudarmstadt.ukp.inception.schema.api.event.LayerConfigurationChangedEvent; import de.tudarmstadt.ukp.inception.support.logging.Logging; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; public class CasStorageServiceImplTest { diff --git a/inception/inception-annotation-storage/src/test/java/de/tudarmstadt/ukp/inception/annotation/storage/driver/filesystem/CasPersistenceUtilsTest.java b/inception/inception-annotation-storage/src/test/java/de/tudarmstadt/ukp/inception/annotation/storage/driver/filesystem/CasPersistenceUtilsTest.java index 133a36bc7e5..379f0e7273b 100644 --- a/inception/inception-annotation-storage/src/test/java/de/tudarmstadt/ukp/inception/annotation/storage/driver/filesystem/CasPersistenceUtilsTest.java +++ b/inception/inception-annotation-storage/src/test/java/de/tudarmstadt/ukp/inception/annotation/storage/driver/filesystem/CasPersistenceUtilsTest.java @@ -32,8 +32,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; public class CasPersistenceUtilsTest { diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/SentenceOrientedPagingStrategy.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/SentenceOrientedPagingStrategy.java index 024507bf96a..c76fb306a69 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/SentenceOrientedPagingStrategy.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/SentenceOrientedPagingStrategy.java @@ -17,7 +17,7 @@ */ package de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectSentences; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectSentences; import java.util.ArrayList; import java.util.List; diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/TokenWrappingPagingStrategy.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/TokenWrappingPagingStrategy.java index 78a32752d5b..5056a1fa3d2 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/TokenWrappingPagingStrategy.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/TokenWrappingPagingStrategy.java @@ -31,9 +31,9 @@ import org.apache.wicket.model.IModel; import de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState; import de.tudarmstadt.ukp.inception.rendering.paging.Unit; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; public class TokenWrappingPagingStrategy extends PagingStrategy_ImplBase diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/util/TypeSystemAnalysis.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/util/TypeSystemAnalysis.java index 42e7b7e3862..6c52013aa46 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/util/TypeSystemAnalysis.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/util/TypeSystemAnalysis.java @@ -59,6 +59,7 @@ import de.tudarmstadt.ukp.clarin.webanno.model.MultiValueMode; import de.tudarmstadt.ukp.clarin.webanno.model.OverlapMode; import de.tudarmstadt.ukp.inception.support.WebAnnoConst; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; public class TypeSystemAnalysis { diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/chain/ChainAdapter.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/chain/ChainAdapter.java index 1546b5c852a..03d42b0c432 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/chain/ChainAdapter.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/chain/ChainAdapter.java @@ -17,9 +17,9 @@ */ package de.tudarmstadt.ukp.inception.annotation.layer.chain; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.isSame; import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.COREFERENCE_RELATION_FEATURE; import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.COREFERENCE_TYPE_FEATURE; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.isSame; import static java.lang.System.currentTimeMillis; import static java.util.Collections.emptyList; @@ -39,7 +39,6 @@ import org.springframework.context.ApplicationEventPublisher; import org.springframework.core.annotation.AnnotationAwareOrderComparator; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer; import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument; @@ -55,6 +54,7 @@ import de.tudarmstadt.ukp.inception.schema.api.layer.LayerSupportRegistry; import de.tudarmstadt.ukp.inception.support.logging.LogMessage; import de.tudarmstadt.ukp.inception.support.uima.ICasUtil; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; /** * Manage interactions with annotations on a chain layer. diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationCrossSentenceBehavior.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationCrossSentenceBehavior.java index 9c778c37477..d8960353b23 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationCrossSentenceBehavior.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationCrossSentenceBehavior.java @@ -17,9 +17,9 @@ */ package de.tudarmstadt.ukp.inception.annotation.layer.relation; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.isBeginEndInSameSentence; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.isBeginInSameSentence; import static de.tudarmstadt.ukp.inception.rendering.vmodel.VCommentType.ERROR; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.isBeginEndInSameSentence; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.isBeginInSameSentence; import static java.util.Collections.emptyList; import static org.apache.uima.fit.util.CasUtil.getType; @@ -35,7 +35,6 @@ import org.apache.uima.jcas.tcas.Annotation; import de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.MultipleSentenceCoveredException; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; import de.tudarmstadt.ukp.inception.rendering.vmodel.VArc; import de.tudarmstadt.ukp.inception.rendering.vmodel.VComment; @@ -45,6 +44,7 @@ import de.tudarmstadt.ukp.inception.schema.api.adapter.TypeAdapter; import de.tudarmstadt.ukp.inception.support.logging.LogMessage; import de.tudarmstadt.ukp.inception.support.uima.ICasUtil; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; /** *

diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationOverlapBehavior.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationOverlapBehavior.java index 9258cb9cdbc..1367b77b71d 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationOverlapBehavior.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationOverlapBehavior.java @@ -17,8 +17,8 @@ */ package de.tudarmstadt.ukp.inception.annotation.layer.relation; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.isSame; import static de.tudarmstadt.ukp.inception.rendering.vmodel.VCommentType.ERROR; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.isSame; import static java.util.Collections.emptyList; import static org.apache.uima.fit.util.CasUtil.getType; import static org.apache.uima.fit.util.CasUtil.select; diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanAnchoringModeBehavior.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanAnchoringModeBehavior.java index 0275fd91b89..03175f024a2 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanAnchoringModeBehavior.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanAnchoringModeBehavior.java @@ -17,7 +17,7 @@ */ package de.tudarmstadt.ukp.inception.annotation.layer.span; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectOverlapping; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectOverlapping; import static org.apache.uima.fit.util.CasUtil.getType; import java.util.Arrays; diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanCrossSentenceBehavior.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanCrossSentenceBehavior.java index 77488c635af..52822463fb4 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanCrossSentenceBehavior.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanCrossSentenceBehavior.java @@ -17,9 +17,9 @@ */ package de.tudarmstadt.ukp.inception.annotation.layer.span; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.isBeginEndInSameSentence; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectOverlapping; import static de.tudarmstadt.ukp.inception.rendering.vmodel.VCommentType.ERROR; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.isBeginEndInSameSentence; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectOverlapping; import static java.util.Collections.emptyList; import static org.apache.uima.fit.util.CasUtil.getType; import static org.apache.uima.fit.util.CasUtil.select; @@ -38,7 +38,6 @@ import org.apache.uima.cas.text.AnnotationFS; import de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.MultipleSentenceCoveredException; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; import de.tudarmstadt.ukp.inception.annotation.layer.chain.ChainLayerSupport; import de.tudarmstadt.ukp.inception.rendering.vmodel.VComment; @@ -49,6 +48,7 @@ import de.tudarmstadt.ukp.inception.schema.api.adapter.TypeAdapter; import de.tudarmstadt.ukp.inception.schema.api.layer.LayerSupport; import de.tudarmstadt.ukp.inception.support.logging.LogMessage; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; /** * Ensure that annotations do not cross sentence boundaries. For chain layers, this check applies diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanOverlapBehavior.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanOverlapBehavior.java index 917fb7ad0a8..9391c649c1b 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanOverlapBehavior.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanOverlapBehavior.java @@ -17,8 +17,8 @@ */ package de.tudarmstadt.ukp.inception.annotation.layer.span; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectOverlapping; import static de.tudarmstadt.ukp.inception.rendering.vmodel.VCommentType.ERROR; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectOverlapping; import static org.apache.uima.fit.util.CasUtil.getType; import static org.apache.uima.fit.util.CasUtil.select; import static org.apache.uima.fit.util.CasUtil.selectAt; diff --git a/inception/inception-api-annotation/src/test/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/util/WebAnnoCasUtilTest.java b/inception/inception-api-annotation/src/test/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/util/WebAnnoCasUtilTest.java index a8c22387a06..b6033c8240e 100644 --- a/inception/inception-api-annotation/src/test/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/util/WebAnnoCasUtilTest.java +++ b/inception/inception-api-annotation/src/test/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/util/WebAnnoCasUtilTest.java @@ -17,8 +17,8 @@ */ package de.tudarmstadt.ukp.clarin.webanno.api.annotation.util; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.createCas; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getRealCas; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.createCas; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.getRealCas; import static org.apache.uima.cas.CAS.TYPE_NAME_DOCUMENT_ANNOTATION; import static org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription; import static org.assertj.core.api.Assertions.assertThat; @@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test; import de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; public class WebAnnoCasUtilTest { diff --git a/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/controller/BratAjaxCasUtilTest.java b/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/controller/BratAjaxCasUtilTest.java index 69a603f8937..df7bb01a0ef 100644 --- a/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/controller/BratAjaxCasUtilTest.java +++ b/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/controller/BratAjaxCasUtilTest.java @@ -17,8 +17,8 @@ */ package de.tudarmstadt.ukp.clarin.webanno.brat.controller; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.isBeginEndInSameSentence; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.isBeginInSameSentence; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.isBeginEndInSameSentence; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.isBeginInSameSentence; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/render/BratSerializerImplTest.java b/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/render/BratSerializerImplTest.java index 1aa74f426b5..17b42b19d05 100644 --- a/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/render/BratSerializerImplTest.java +++ b/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/render/BratSerializerImplTest.java @@ -51,7 +51,6 @@ import de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.LabelRenderer; import de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.PreRenderer; import de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.PreRendererImpl; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.brat.config.BratAnnotationEditorPropertiesImpl; import de.tudarmstadt.ukp.clarin.webanno.brat.message.GetDocumentResponse; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature; @@ -77,6 +76,7 @@ import de.tudarmstadt.ukp.inception.schema.api.AnnotationSchemaService; import de.tudarmstadt.ukp.inception.schema.service.FeatureSupportRegistryImpl; import de.tudarmstadt.ukp.inception.support.json.JSONUtil; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; @ExtendWith(MockitoExtension.class) public class BratSerializerImplTest diff --git a/inception/inception-concept-linking/src/main/java/de/tudarmstadt/ukp/inception/conceptlinking/recommender/NamedEntityLinker.java b/inception/inception-concept-linking/src/main/java/de/tudarmstadt/ukp/inception/conceptlinking/recommender/NamedEntityLinker.java index 0929ad0bde2..1ec839a07da 100644 --- a/inception/inception-concept-linking/src/main/java/de/tudarmstadt/ukp/inception/conceptlinking/recommender/NamedEntityLinker.java +++ b/inception/inception-concept-linking/src/main/java/de/tudarmstadt/ukp/inception/conceptlinking/recommender/NamedEntityLinker.java @@ -17,7 +17,7 @@ */ package de.tudarmstadt.ukp.inception.conceptlinking.recommender; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectOverlapping; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectOverlapping; import static org.apache.uima.fit.util.CasUtil.getType; import java.util.ArrayList; diff --git a/inception/inception-concept-linking/src/main/java/de/tudarmstadt/ukp/inception/conceptlinking/service/ConceptLinkingServiceImpl.java b/inception/inception-concept-linking/src/main/java/de/tudarmstadt/ukp/inception/conceptlinking/service/ConceptLinkingServiceImpl.java index ac2cc14ba78..b3dd2550e95 100644 --- a/inception/inception-concept-linking/src/main/java/de/tudarmstadt/ukp/inception/conceptlinking/service/ConceptLinkingServiceImpl.java +++ b/inception/inception-concept-linking/src/main/java/de/tudarmstadt/ukp/inception/conceptlinking/service/ConceptLinkingServiceImpl.java @@ -17,8 +17,6 @@ */ package de.tudarmstadt.ukp.inception.conceptlinking.service; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectSentenceCovering; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectTokensCovered; import static de.tudarmstadt.ukp.inception.conceptlinking.model.CandidateEntity.KEY_LABEL_NC; import static de.tudarmstadt.ukp.inception.conceptlinking.model.CandidateEntity.KEY_MENTION; import static de.tudarmstadt.ukp.inception.conceptlinking.model.CandidateEntity.KEY_MENTION_CONTEXT; @@ -26,6 +24,8 @@ import static de.tudarmstadt.ukp.inception.conceptlinking.model.CandidateEntity.KEY_QUERY; import static de.tudarmstadt.ukp.inception.conceptlinking.model.CandidateEntity.KEY_QUERY_BEST_MATCH_TERM_NC; import static de.tudarmstadt.ukp.inception.conceptlinking.model.CandidateEntity.KEY_QUERY_NC; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectSentenceCovering; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectTokensCovered; import static java.lang.System.currentTimeMillis; import static java.util.Arrays.asList; import static java.util.Collections.unmodifiableList; diff --git a/inception/inception-curation-legacy/src/main/java/de/tudarmstadt/ukp/clarin/webanno/curation/casdiff/CasDiff.java b/inception/inception-curation-legacy/src/main/java/de/tudarmstadt/ukp/clarin/webanno/curation/casdiff/CasDiff.java index 43fa6379c75..49f641f000a 100644 --- a/inception/inception-curation-legacy/src/main/java/de/tudarmstadt/ukp/clarin/webanno/curation/casdiff/CasDiff.java +++ b/inception/inception-curation-legacy/src/main/java/de/tudarmstadt/ukp/clarin/webanno/curation/casdiff/CasDiff.java @@ -59,7 +59,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter; import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter_ImplBase; import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.Position; @@ -73,6 +72,7 @@ import de.tudarmstadt.ukp.inception.annotation.layer.span.SpanLayerSupport; import de.tudarmstadt.ukp.inception.schema.api.AnnotationSchemaService; import de.tudarmstadt.ukp.inception.support.uima.ICasUtil; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; public class CasDiff { diff --git a/inception/inception-curation-legacy/src/main/java/de/tudarmstadt/ukp/clarin/webanno/curation/casdiff/relation/RelationDiffAdapter.java b/inception/inception-curation-legacy/src/main/java/de/tudarmstadt/ukp/clarin/webanno/curation/casdiff/relation/RelationDiffAdapter.java index 1870abab6de..0f29717d105 100644 --- a/inception/inception-curation-legacy/src/main/java/de/tudarmstadt/ukp/clarin/webanno/curation/casdiff/relation/RelationDiffAdapter.java +++ b/inception/inception-curation-legacy/src/main/java/de/tudarmstadt/ukp/clarin/webanno/curation/casdiff/relation/RelationDiffAdapter.java @@ -33,11 +33,11 @@ import org.apache.uima.fit.util.CasUtil; import org.apache.uima.fit.util.FSUtil; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.LinkCompareBehavior; import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter_ImplBase; import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.Position; import de.tudarmstadt.ukp.dkpro.core.api.syntax.type.dependency.Dependency; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; public class RelationDiffAdapter extends DiffAdapter_ImplBase 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 4ad640c22bc..6e5b2378788 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 @@ -30,7 +30,6 @@ import org.apache.uima.cas.text.AnnotationPredicates; import org.apache.uima.fit.util.FSUtil; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.LinkCompareBehavior; import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter_ImplBase; import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.Position; @@ -39,6 +38,7 @@ import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; import de.tudarmstadt.ukp.inception.annotation.layer.span.SpanRenderer; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; public class SpanDiffAdapter extends DiffAdapter_ImplBase diff --git a/inception/inception-curation/src/main/java/de/tudarmstadt/ukp/inception/curation/merge/CasMerge.java b/inception/inception-curation/src/main/java/de/tudarmstadt/ukp/inception/curation/merge/CasMerge.java index 7a666245025..01bbb125ba5 100644 --- a/inception/inception-curation/src/main/java/de/tudarmstadt/ukp/inception/curation/merge/CasMerge.java +++ b/inception/inception-curation/src/main/java/de/tudarmstadt/ukp/inception/curation/merge/CasMerge.java @@ -17,19 +17,19 @@ */ package de.tudarmstadt.ukp.inception.curation.merge; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.copyDocumentMetadata; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.createDocumentMetadata; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.createSentence; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.createToken; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.exists; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.isPrimitiveType; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectSentences; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectTokens; import static de.tudarmstadt.ukp.clarin.webanno.model.MultiValueMode.ARRAY; import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.FEAT_REL_SOURCE; import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.FEAT_REL_TARGET; import static de.tudarmstadt.ukp.inception.support.uima.ICasUtil.getAddr; import static de.tudarmstadt.ukp.inception.support.uima.ICasUtil.selectAnnotationByAddr; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.copyDocumentMetadata; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.createDocumentMetadata; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.createSentence; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.createToken; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.exists; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.isPrimitiveType; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectSentences; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectTokens; import static java.util.Arrays.asList; import static java.util.function.Function.identity; import static java.util.stream.Collectors.toList; @@ -66,7 +66,6 @@ import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.LoadingCache; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.Configuration; import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.ConfigurationSet; import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult; @@ -97,6 +96,7 @@ import de.tudarmstadt.ukp.inception.schema.api.feature.LinkWithRoleModel; import de.tudarmstadt.ukp.inception.support.json.JSONUtil; import de.tudarmstadt.ukp.inception.support.logging.LogMessage; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; /** * Do a merge CAS out of multiple user annotations diff --git a/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/NoMultipleIncomingRelationsCheck.java b/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/NoMultipleIncomingRelationsCheck.java index b70eac6eded..0ebe7fc9c95 100644 --- a/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/NoMultipleIncomingRelationsCheck.java +++ b/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/NoMultipleIncomingRelationsCheck.java @@ -34,12 +34,12 @@ import org.apache.uima.cas.Type; import org.apache.uima.cas.text.AnnotationFS; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer; import de.tudarmstadt.ukp.clarin.webanno.model.Project; import de.tudarmstadt.ukp.dkpro.core.api.syntax.type.dependency.Dependency; import de.tudarmstadt.ukp.inception.schema.api.AnnotationSchemaService; import de.tudarmstadt.ukp.inception.support.logging.LogMessage; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; public class NoMultipleIncomingRelationsCheck implements Check diff --git a/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/NoZeroSizeTokensAndSentencesCheck.java b/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/NoZeroSizeTokensAndSentencesCheck.java index 5a12d8b2f78..28cc1d80ed3 100644 --- a/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/NoZeroSizeTokensAndSentencesCheck.java +++ b/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/NoZeroSizeTokensAndSentencesCheck.java @@ -17,8 +17,8 @@ */ package de.tudarmstadt.ukp.clarin.webanno.diag.checks; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectSentences; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectTokens; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectSentences; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectTokens; import java.util.List; diff --git a/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/UnreachableAnnotationsCheck.java b/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/UnreachableAnnotationsCheck.java index 6861f4891b4..b49a7d5c443 100644 --- a/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/UnreachableAnnotationsCheck.java +++ b/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/checks/UnreachableAnnotationsCheck.java @@ -17,7 +17,7 @@ */ package de.tudarmstadt.ukp.clarin.webanno.diag.checks; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getRealCas; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.getRealCas; import static java.util.function.Function.identity; import static java.util.stream.Collectors.counting; import static java.util.stream.Collectors.groupingBy; @@ -31,9 +31,9 @@ import org.apache.uima.cas.impl.CASImpl; import org.apache.uima.resource.ResourceInitializationException; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.model.Project; import de.tudarmstadt.ukp.inception.support.logging.LogMessage; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; public class UnreachableAnnotationsCheck implements Check diff --git a/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/repairs/RemoveZeroSizeTokensAndSentencesRepair.java b/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/repairs/RemoveZeroSizeTokensAndSentencesRepair.java index 2a2c736a406..a4d92709874 100644 --- a/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/repairs/RemoveZeroSizeTokensAndSentencesRepair.java +++ b/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/repairs/RemoveZeroSizeTokensAndSentencesRepair.java @@ -17,8 +17,8 @@ */ package de.tudarmstadt.ukp.clarin.webanno.diag.repairs; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectSentences; import static de.tudarmstadt.ukp.inception.support.logging.LogLevel.INFO; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectSentences; import java.util.List; @@ -26,10 +26,10 @@ import org.apache.uima.cas.text.AnnotationFS; import org.apache.uima.fit.util.FSUtil; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.diag.repairs.Repair.Safe; import de.tudarmstadt.ukp.clarin.webanno.model.Project; import de.tudarmstadt.ukp.inception.support.logging.LogMessage; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; @Safe(false) public class RemoveZeroSizeTokensAndSentencesRepair diff --git a/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/repairs/UpgradeCasRepair.java b/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/repairs/UpgradeCasRepair.java index 454e5f282e9..0fb9004ec13 100644 --- a/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/repairs/UpgradeCasRepair.java +++ b/inception/inception-diag/src/main/java/de/tudarmstadt/ukp/clarin/webanno/diag/repairs/UpgradeCasRepair.java @@ -17,8 +17,8 @@ */ package de.tudarmstadt.ukp.clarin.webanno.diag.repairs; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getRealCas; import static de.tudarmstadt.ukp.clarin.webanno.diag.checks.UnreachableAnnotationsCheck.countFeatureStructures; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.getRealCas; import static org.apache.uima.cas.impl.Serialization.serializeCASComplete; import java.io.IOException; @@ -32,11 +32,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.diag.repairs.Repair.Safe; import de.tudarmstadt.ukp.clarin.webanno.model.Project; import de.tudarmstadt.ukp.inception.schema.api.AnnotationSchemaService; import de.tudarmstadt.ukp.inception.support.logging.LogMessage; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; /** * Ensures that the CAS is up-to-date with the project type system. It performs the same operation diff --git a/inception/inception-example-imls-data-majority/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/datamajority/DataMajorityNerRecommender.java b/inception/inception-example-imls-data-majority/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/datamajority/DataMajorityNerRecommender.java index 8289aebad56..879ea387eb5 100644 --- a/inception/inception-example-imls-data-majority/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/datamajority/DataMajorityNerRecommender.java +++ b/inception/inception-example-imls-data-majority/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/datamajority/DataMajorityNerRecommender.java @@ -17,9 +17,9 @@ */ package de.tudarmstadt.ukp.inception.recommendation.imls.datamajority; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectOverlapping; import static de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult.toEvaluationResult; import static de.tudarmstadt.ukp.inception.recommendation.api.recommender.TrainingCapability.TRAINING_REQUIRED; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectOverlapping; import static org.apache.commons.lang3.StringUtils.isNotEmpty; import java.util.ArrayList; diff --git a/inception/inception-export/src/main/java/de/tudarmstadt/ukp/inception/export/DocumentImportExportServiceImpl.java b/inception/inception-export/src/main/java/de/tudarmstadt/ukp/inception/export/DocumentImportExportServiceImpl.java index 01372c5648a..8fdc692f327 100644 --- a/inception/inception-export/src/main/java/de/tudarmstadt/ukp/inception/export/DocumentImportExportServiceImpl.java +++ b/inception/inception-export/src/main/java/de/tudarmstadt/ukp/inception/export/DocumentImportExportServiceImpl.java @@ -17,8 +17,6 @@ */ package de.tudarmstadt.ukp.inception.export; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.exists; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getRealCas; import static de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasAccessMode.EXCLUSIVE_WRITE_ACCESS; import static de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasAccessMode.UNMANAGED_ACCESS; import static de.tudarmstadt.ukp.inception.project.api.ProjectService.DOCUMENT_FOLDER; @@ -26,6 +24,8 @@ import static de.tudarmstadt.ukp.inception.project.api.ProjectService.SOURCE_FOLDER; import static de.tudarmstadt.ukp.inception.project.api.ProjectService.withProjectLogger; import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.CURATION_USER; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.exists; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.getRealCas; import static java.util.Collections.unmodifiableList; import static java.util.Collections.unmodifiableMap; import static java.util.Comparator.comparing; @@ -69,7 +69,6 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.transaction.annotation.Transactional; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasStorageService; import de.tudarmstadt.ukp.clarin.webanno.api.export.DocumentImportExportService; import de.tudarmstadt.ukp.clarin.webanno.api.format.FormatSupport; @@ -95,6 +94,8 @@ import de.tudarmstadt.ukp.inception.schema.api.AnnotationSchemaService; import de.tudarmstadt.ukp.inception.support.logging.BaseLoggers; import de.tudarmstadt.ukp.inception.support.logging.LogMessage; +import de.tudarmstadt.ukp.inception.support.uima.SegmentationUtils; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; /** *

diff --git a/inception/inception-export/src/test/java/de/tudarmstadt/ukp/inception/export/SegmentationUtilsTest.java b/inception/inception-export/src/test/java/de/tudarmstadt/ukp/inception/export/SegmentationUtilsTest.java index 3aad41b74de..a5badf04fa3 100644 --- a/inception/inception-export/src/test/java/de/tudarmstadt/ukp/inception/export/SegmentationUtilsTest.java +++ b/inception/inception-export/src/test/java/de/tudarmstadt/ukp/inception/export/SegmentationUtilsTest.java @@ -30,6 +30,7 @@ import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Paragraph; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; +import de.tudarmstadt.ukp.inception.support.uima.SegmentationUtils; public class SegmentationUtilsTest { diff --git a/inception/inception-external-search-pubmed/src/main/java/de/tudarmstadt/ukp/inception/externalsearch/pubmed/PubMedCentralProvider.java b/inception/inception-external-search-pubmed/src/main/java/de/tudarmstadt/ukp/inception/externalsearch/pubmed/PubMedCentralProvider.java index 9b23981cc33..b27051d8315 100644 --- a/inception/inception-external-search-pubmed/src/main/java/de/tudarmstadt/ukp/inception/externalsearch/pubmed/PubMedCentralProvider.java +++ b/inception/inception-external-search-pubmed/src/main/java/de/tudarmstadt/ukp/inception/externalsearch/pubmed/PubMedCentralProvider.java @@ -35,7 +35,6 @@ import org.apache.uima.UIMAException; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.model.Project; import de.tudarmstadt.ukp.inception.externalsearch.ExternalSearchProvider; import de.tudarmstadt.ukp.inception.externalsearch.ExternalSearchResult; @@ -46,6 +45,7 @@ import de.tudarmstadt.ukp.inception.io.bioc.BioCFormatSupport; import de.tudarmstadt.ukp.inception.io.bioc.model.BioCToCas; import de.tudarmstadt.ukp.inception.schema.api.AnnotationSchemaService; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; public class PubMedCentralProvider implements ExternalSearchProvider diff --git a/inception/inception-imls-external/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/external/v1/ExternalRecommender.java b/inception/inception-imls-external/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/external/v1/ExternalRecommender.java index 42b4dbb2f88..25bae96ed48 100644 --- a/inception/inception-imls-external/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/external/v1/ExternalRecommender.java +++ b/inception/inception-imls-external/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/external/v1/ExternalRecommender.java @@ -17,9 +17,9 @@ */ package de.tudarmstadt.ukp.inception.recommendation.imls.external.v1; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getRealCas; import static de.tudarmstadt.ukp.inception.recommendation.api.recommender.TrainingCapability.TRAINING_NOT_SUPPORTED; import static de.tudarmstadt.ukp.inception.recommendation.api.recommender.TrainingCapability.TRAINING_REQUIRED; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.getRealCas; import static java.lang.String.format; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Arrays.stream; @@ -60,7 +60,6 @@ import org.springframework.http.HttpHeaders; import org.xml.sax.SAXException; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.api.type.CASMetadata; import de.tudarmstadt.ukp.inception.recommendation.api.evaluation.DataSplitter; import de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult; @@ -78,6 +77,7 @@ import de.tudarmstadt.ukp.inception.recommendation.imls.external.v1.model.Metadata; import de.tudarmstadt.ukp.inception.rendering.model.Range; import de.tudarmstadt.ukp.inception.support.json.JSONUtil; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; import de.tudarmstadt.ukp.inception.support.xml.sanitizer.IllegalXmlCharacterSanitizingContentHandler; public class ExternalRecommender diff --git a/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/prompt/PerAnnotationContextGenerator.java b/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/prompt/PerAnnotationContextGenerator.java index 16eb7acb259..3f6f02a3804 100644 --- a/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/prompt/PerAnnotationContextGenerator.java +++ b/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/prompt/PerAnnotationContextGenerator.java @@ -17,7 +17,7 @@ */ package de.tudarmstadt.ukp.inception.recommendation.imls.ollama.prompt; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectOverlapping; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectOverlapping; import java.util.stream.Stream; diff --git a/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/prompt/PerSentenceContextGenerator.java b/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/prompt/PerSentenceContextGenerator.java index 300565c210c..613326bf6d3 100644 --- a/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/prompt/PerSentenceContextGenerator.java +++ b/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/prompt/PerSentenceContextGenerator.java @@ -17,7 +17,7 @@ */ package de.tudarmstadt.ukp.inception.recommendation.imls.ollama.prompt; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectOverlapping; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectOverlapping; import java.util.stream.Stream; diff --git a/inception/inception-imls-opennlp/pom.xml b/inception/inception-imls-opennlp/pom.xml index a368c338f54..d612b7fb864 100644 --- a/inception/inception-imls-opennlp/pom.xml +++ b/inception/inception-imls-opennlp/pom.xml @@ -48,6 +48,10 @@ de.tudarmstadt.ukp.inception.app inception-support + + de.tudarmstadt.ukp.inception.app + inception-layer-docmetadata + it.unimi.dsi diff --git a/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatMetadataRecommender.java b/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatMetadataRecommender.java new file mode 100644 index 00000000000..9d1785dddc0 --- /dev/null +++ b/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatMetadataRecommender.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Technische Universität Darmstadt under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The Technische Universität Darmstadt + * 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. + * + * 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 de.tudarmstadt.ukp.inception.recommendation.imls.opennlp.doccat; + +import static org.apache.uima.fit.util.CasUtil.getType; + +import java.lang.invoke.MethodHandles; +import java.util.ArrayList; +import java.util.List; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; +import org.apache.uima.jcas.tcas.DocumentAnnotation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; +import de.tudarmstadt.ukp.inception.recommendation.api.model.Recommender; +import opennlp.tools.doccat.DocumentSample; + +public class OpenNlpDoccatMetadataRecommender + extends OpenNlpDoccatRecommender +{ + private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + private static final String NO_CATEGORY = ""; + + public OpenNlpDoccatMetadataRecommender(Recommender aRecommender, + OpenNlpDoccatRecommenderTraits aTraits) + { + super(aRecommender, aTraits); + } + + @Override + protected Class getSampleUnit() + { + return DocumentAnnotation.class; + } + + @Override + protected Class getDataPointUnit() + { + return DocumentAnnotation.class; + } + + @Override + protected List extractSamples(List aCasses) + { + var samples = new ArrayList(); + + for (var cas : aCasses) { + var tokenTexts = cas.select(Token.class).map(AnnotationFS::getCoveredText) + .toArray(String[]::new); + + var annotationType = getType(cas, layerName); + var annotation = cas.select(annotationType).nullOK().get(); + if (annotation == null) { + continue; + } + + var feature = annotationType.getFeatureByBaseName(featureName); + var label = annotation.getFeatureValueAsString(feature); + var nameSample = new DocumentSample(label != null ? label : NO_CATEGORY, tokenTexts); + if (nameSample.getCategory() != null) { + samples.add(nameSample); + } + } + + return samples; + } +} diff --git a/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatMetadataRecommenderFactory.java b/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatMetadataRecommenderFactory.java new file mode 100644 index 00000000000..9719cec03c8 --- /dev/null +++ b/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatMetadataRecommenderFactory.java @@ -0,0 +1,89 @@ +/* + * Copyright 2018 + * Ubiquitous Knowledge Processing (UKP) Lab + * Technische Universität Darmstadt + * + * Licensed to the Technische Universität Darmstadt under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The Technische Universität Darmstadt + * 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. + * + * 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 de.tudarmstadt.ukp.inception.recommendation.imls.opennlp.doccat; + +import org.apache.uima.cas.CAS; +import org.apache.wicket.model.IModel; +import org.springframework.stereotype.Component; + +import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature; +import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer; +import de.tudarmstadt.ukp.inception.recommendation.api.model.Recommender; +import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationEngine; +import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationEngineFactoryImplBase; +import de.tudarmstadt.ukp.inception.ui.core.docanno.layer.DocumentMetadataLayerSupport; + +@Component +public class OpenNlpDoccatMetadataRecommenderFactory + extends RecommendationEngineFactoryImplBase +{ + // This is a string literal so we can rename/refactor the class without it changing its ID + // and without the database starting to refer to non-existing recommendation tools. + public static final String ID = "de.tudarmstadt.ukp.inception.recommendation.imls.opennlp.doccat.OpenNlpDoccatMetadataRecommender"; + + @Override + public String getId() + { + return ID; + } + + @Override + public RecommendationEngine build(Recommender aRecommender) + { + OpenNlpDoccatRecommenderTraits traits = new OpenNlpDoccatRecommenderTraits(); + return new OpenNlpDoccatMetadataRecommender(aRecommender, traits); + } + + @Override + public String getName() + { + return "Document Classifier (OpenNLP Document Categorizer)"; + } + + @Override + public boolean accepts(AnnotationLayer aLayer, AnnotationFeature aFeature) + { + if (aLayer == null || aFeature == null) { + return false; + } + + var compatibleSpanLayer = DocumentMetadataLayerSupport.TYPE.equals(aLayer.getType()); + + var compatibleFeature = CAS.TYPE_NAME_STRING.equals(aFeature.getType()) + || aFeature.isVirtualFeature(); + + return compatibleSpanLayer && compatibleFeature; + } + + @Override + public OpenNlpDoccatRecommenderTraits createTraits() + { + return new OpenNlpDoccatRecommenderTraits(); + } + + @Override + public OpenNlpDoccatRecommenderTraitsEditor createTraitsEditor(String aId, + IModel aModel) + { + return new OpenNlpDoccatRecommenderTraitsEditor(aId, aModel); + } +} diff --git a/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatRecommender.java b/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatRecommender.java index d04591bfdf9..6ee353db93f 100644 --- a/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatRecommender.java +++ b/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatRecommender.java @@ -17,15 +17,16 @@ */ package de.tudarmstadt.ukp.inception.recommendation.imls.opennlp.doccat; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectOverlapping; import static de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult.toEvaluationResult; import static de.tudarmstadt.ukp.inception.rendering.model.Range.rangeCoveringAnnotations; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectOverlapping; import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.uima.fit.util.CasUtil.getType; import static org.apache.uima.fit.util.CasUtil.indexCovered; import static org.apache.uima.fit.util.CasUtil.selectCovered; import java.io.IOException; +import java.lang.invoke.MethodHandles; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -35,8 +36,10 @@ import org.apache.commons.lang3.math.NumberUtils; import org.apache.uima.cas.CAS; import org.apache.uima.cas.Feature; +import org.apache.uima.cas.FeatureStructure; import org.apache.uima.cas.Type; import org.apache.uima.cas.text.AnnotationFS; +import org.apache.uima.jcas.cas.AnnotationBase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,17 +68,14 @@ public class OpenNlpDoccatRecommender { public static final Key KEY_MODEL = new Key<>("model"); - private static final Logger LOG = LoggerFactory.getLogger(OpenNlpDoccatRecommender.class); + private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static final String NO_CATEGORY = ""; - private static final Class SAMPLE_UNIT = Sentence.class; - private static final Class DATAPOINT_UNIT = Sentence.class; - private static final int MIN_TRAINING_SET_SIZE = 2; private static final int MIN_TEST_SET_SIZE = 2; - private final OpenNlpDoccatRecommenderTraits traits; + protected final OpenNlpDoccatRecommenderTraits traits; public OpenNlpDoccatRecommender(Recommender aRecommender, OpenNlpDoccatRecommenderTraits aTraits) @@ -85,6 +85,16 @@ public OpenNlpDoccatRecommender(Recommender aRecommender, traits = aTraits; } + protected Class getSampleUnit() + { + return Sentence.class; + } + + protected Class getDataPointUnit() + { + return Sentence.class; + } + @Override public boolean isReadyForPrediction(RecommenderContext aContext) { @@ -135,15 +145,17 @@ public Range predict(RecommenderContext aContext, CAS aCas, int aBegin, int aEnd var finder = new DocumentCategorizerME(model); - var sampleUnitType = getType(aCas, SAMPLE_UNIT); + var sampleUnitType = getType(aCas, getSampleUnit()); var predictedType = getPredictedType(aCas); var tokenType = getType(aCas, Token.class); var scoreFeature = getScoreFeature(aCas); var predictedFeature = getPredictedFeature(aCas); var isPredictionFeature = getIsPredictionFeature(aCas); + var isPredictingAnnotation = aCas.getAnnotationType().subsumes(predictedType); var units = selectOverlapping(aCas, sampleUnitType, aBegin, aEnd); var predictionCount = 0; + for (var unit : units) { if (predictionCount >= traits.getPredictionLimit()) { break; @@ -158,7 +170,13 @@ public Range predict(RecommenderContext aContext, CAS aCas, int aBegin, int aEnd var outcome = finder.categorize(tokens); var label = finder.getBestCategory(outcome); - var annotation = aCas.createAnnotation(predictedType, unit.getBegin(), unit.getEnd()); + FeatureStructure annotation; + if (isPredictingAnnotation) { + annotation = aCas.createAnnotation(predictedType, unit.getBegin(), unit.getEnd()); + } + else { + annotation = aCas.createFS(predictedType); + } annotation.setStringValue(predictedFeature, label); annotation.setDoubleValue(scoreFeature, NumberUtils.max(outcome)); annotation.setBooleanValue(isPredictionFeature, true); @@ -208,8 +226,8 @@ public EvaluationResult evaluate(List aCasses, DataSplitter aDataSplitter) data.size(), (MIN_TRAINING_SET_SIZE + MIN_TEST_SET_SIZE)); LOG.info(msg); - var result = new EvaluationResult(DATAPOINT_UNIT.getSimpleName(), - SAMPLE_UNIT.getSimpleName(), trainingSetSize, testSetSize, trainRatio); + var result = new EvaluationResult(getDataPointUnit().getSimpleName(), + getSampleUnit().getSimpleName(), trainingSetSize, testSetSize, trainRatio); result.setEvaluationSkipped(true); result.setErrorMsg(msg); return result; @@ -219,8 +237,8 @@ public EvaluationResult evaluate(List aCasses, DataSplitter aDataSplitter) var msg = String.format("Training data requires at least two different labels"); LOG.info(msg); - var result = new EvaluationResult(DATAPOINT_UNIT.getSimpleName(), - SAMPLE_UNIT.getSimpleName(), trainingSetSize, testSetSize, trainRatio); + var result = new EvaluationResult(getDataPointUnit().getSimpleName(), + getSampleUnit().getSimpleName(), trainingSetSize, testSetSize, trainRatio); result.setEvaluationSkipped(true); result.setErrorMsg(msg); return result; @@ -237,18 +255,18 @@ public EvaluationResult evaluate(List aCasses, DataSplitter aDataSplitter) var result = testSet.stream() .map(sample -> new LabelPair(sample.getCategory(), doccat.getBestCategory(doccat.categorize(sample.getText())))) - .collect(toEvaluationResult(DATAPOINT_UNIT.getSimpleName(), - SAMPLE_UNIT.getSimpleName(), trainingSetSize, testSetSize, trainRatio, + .collect(toEvaluationResult(getDataPointUnit().getSimpleName(), + getSampleUnit().getSimpleName(), trainingSetSize, testSetSize, trainRatio, NO_CATEGORY)); return result; } - private List extractSamples(List aCasses) + protected List extractSamples(List aCasses) { var samples = new ArrayList(); casses: for (CAS cas : aCasses) { - Type sampleUnitType = getType(cas, SAMPLE_UNIT); + Type sampleUnitType = getType(cas, getSampleUnit()); Type tokenType = getType(cas, Token.class); var sampleUnits = indexCovered(cas, sampleUnitType, tokenType); diff --git a/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatRecommenderFactory.java b/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatRecommenderFactory.java index ef414287c16..0d183ea8f8a 100644 --- a/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatRecommenderFactory.java +++ b/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatRecommenderFactory.java @@ -21,16 +21,15 @@ */ package de.tudarmstadt.ukp.inception.recommendation.imls.opennlp.doccat; -import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.SPAN_TYPE; -import static java.util.Arrays.asList; +import static de.tudarmstadt.ukp.clarin.webanno.model.AnchoringMode.SENTENCES; import org.apache.uima.cas.CAS; import org.apache.wicket.model.IModel; import org.springframework.stereotype.Component; -import de.tudarmstadt.ukp.clarin.webanno.model.AnchoringMode; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer; +import de.tudarmstadt.ukp.inception.annotation.layer.span.SpanLayerSupport; import de.tudarmstadt.ukp.inception.recommendation.api.model.Recommender; import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationEngine; import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationEngineFactoryImplBase; @@ -69,9 +68,14 @@ public boolean accepts(AnnotationLayer aLayer, AnnotationFeature aFeature) return false; } - return (asList(AnchoringMode.SENTENCES).contains(aLayer.getAnchoringMode())) - && !aLayer.isCrossSentence() && SPAN_TYPE.equals(aLayer.getType()) - && CAS.TYPE_NAME_STRING.equals(aFeature.getType()) || aFeature.isVirtualFeature(); + var compatibleSpanLayer = SENTENCES == aLayer.getAnchoringMode() // + && !aLayer.isCrossSentence() // + && SpanLayerSupport.TYPE.equals(aLayer.getType()); + + var compatibleFeature = CAS.TYPE_NAME_STRING.equals(aFeature.getType()) + || aFeature.isVirtualFeature(); + + return compatibleSpanLayer && compatibleFeature; } @Override diff --git a/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/ner/OpenNlpNerRecommender.java b/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/ner/OpenNlpNerRecommender.java index 5f6ff523c70..50d7a1a432a 100644 --- a/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/ner/OpenNlpNerRecommender.java +++ b/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/ner/OpenNlpNerRecommender.java @@ -17,9 +17,9 @@ */ package de.tudarmstadt.ukp.inception.recommendation.imls.opennlp.ner; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectOverlapping; import static de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult.toEvaluationResult; import static de.tudarmstadt.ukp.inception.rendering.model.Range.rangeCoveringAnnotations; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectOverlapping; import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.apache.uima.fit.util.CasUtil.getType; diff --git a/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/pos/OpenNlpPosRecommender.java b/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/pos/OpenNlpPosRecommender.java index ef7dd0d7230..23fe7bac5ce 100644 --- a/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/pos/OpenNlpPosRecommender.java +++ b/inception/inception-imls-opennlp/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/pos/OpenNlpPosRecommender.java @@ -17,8 +17,8 @@ */ package de.tudarmstadt.ukp.inception.recommendation.imls.opennlp.pos; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectOverlapping; import static de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult.toEvaluationResult; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectOverlapping; import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isNoneBlank; import static org.apache.uima.fit.util.CasUtil.getType; diff --git a/inception/inception-imls-opennlp/src/test/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatMetadataRecommenderTest.java b/inception/inception-imls-opennlp/src/test/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatMetadataRecommenderTest.java new file mode 100644 index 00000000000..61b2e6bbc70 --- /dev/null +++ b/inception/inception-imls-opennlp/src/test/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatMetadataRecommenderTest.java @@ -0,0 +1,182 @@ +/* + * Licensed to the Technische Universität Darmstadt under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The Technische Universität Darmstadt + * 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. + * + * 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 de.tudarmstadt.ukp.inception.recommendation.imls.opennlp.doccat; + +import static de.tudarmstadt.ukp.inception.support.test.recommendation.RecommenderTestHelper.getPredictionFSes; +import static de.tudarmstadt.ukp.inception.support.uima.FeatureStructureBuilder.buildFS; +import static java.util.Arrays.asList; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; + +import org.apache.uima.cas.CAS; +import org.apache.uima.fit.factory.CasFactory; +import org.apache.uima.fit.factory.TypeSystemDescriptionFactory; +import org.apache.uima.resource.ResourceInitializationException; +import org.apache.uima.resource.metadata.FeatureDescription; +import org.apache.uima.resource.metadata.TypeDescription; +import org.apache.uima.resource.metadata.TypeSystemDescription; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature; +import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer; +import de.tudarmstadt.ukp.inception.recommendation.api.RecommenderTypeSystemUtils; +import de.tudarmstadt.ukp.inception.recommendation.api.evaluation.PercentageBasedSplitter; +import de.tudarmstadt.ukp.inception.recommendation.api.model.Recommender; +import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommenderContext; +import de.tudarmstadt.ukp.inception.support.uima.SegmentationUtils; +import de.tudarmstadt.ukp.inception.ui.core.docanno.layer.DocumentMetadataLayerSupport; + +public class OpenNlpDoccatMetadataRecommenderTest +{ + private RecommenderContext context; + private Recommender recommender; + private OpenNlpDoccatRecommenderTraits traits; + private TypeSystemDescription tsd; + private AnnotationLayer layer; + private AnnotationFeature feature; + private TypeDescription metadataType; + private FeatureDescription metadataLabelFeature; + + @BeforeEach + public void setUp() throws Exception + { + context = new RecommenderContext(); + + tsd = TypeSystemDescriptionFactory.createTypeSystemDescription(); + + metadataType = tsd.addType("custom.Metadata", "", CAS.TYPE_NAME_ANNOTATION_BASE); + metadataLabelFeature = metadataType.addFeature("value", "", CAS.TYPE_NAME_STRING); + + layer = AnnotationLayer.builder() // + .withId(1l) // + .withName(metadataType.getName()) // + .withType(DocumentMetadataLayerSupport.TYPE) // + .build(); + feature = AnnotationFeature.builder() // + .withLayer(layer) // + .withName(metadataLabelFeature.getName()) // + .build(); + recommender = Recommender.builder() // + .withId(1l) // + .withName("recommender") // + .withLayer(layer) // + .withFeature(feature) // + .build(); + + traits = new OpenNlpDoccatRecommenderTraits(); + traits.setNumThreads(2); + traits.setTrainingSetSizeLimit(250); + traits.setPredictionLimit(250); + } + + @Test + public void thatTrainingWorks() throws Exception + { + var sut = new OpenNlpDoccatMetadataRecommender(recommender, traits); + var casList = trainingDocuments(); + + sut.train(context, casList); + + assertThat(context.get(OpenNlpDoccatRecommender.KEY_MODEL)).as("Model has been set") + .isPresent(); + } + + @Test + public void thatPredictionWorks() throws Exception + { + var sut = new OpenNlpDoccatMetadataRecommender(recommender, traits); + var casList = trainingDocuments(); + + sut.train(context, casList); + + var predictionCas = makePredictionCas("I like cars.", feature); + sut.predict(context, predictionCas); + + var predictions = getPredictionFSes(predictionCas, layer.getName()); + + assertThat(predictions).as("Predictions have been written to CAS").isNotEmpty(); + } + + @Test + public void thatEvaluationWorks() throws Exception + { + var splitStrategy = new PercentageBasedSplitter(0.8, 10); + var sut = new OpenNlpDoccatMetadataRecommender(recommender, traits); + var casList = trainingDocuments(); + + var result = sut.evaluate(casList, splitStrategy); + + var fscore = result.computeF1Score(); + var accuracy = result.computeAccuracyScore(); + var precision = result.computePrecisionScore(); + var recall = result.computeRecallScore(); + + System.out.printf("F1-Score: %f%n", fscore); + System.out.printf("Accuracy: %f%n", accuracy); + System.out.printf("Precision: %f%n", precision); + System.out.printf("Recall: %f%n", recall); + + assertThat(fscore).isStrictlyBetween(0.0, 1.0); + assertThat(precision).isStrictlyBetween(0.0, 1.0); + assertThat(recall).isStrictlyBetween(0.0, 1.0); + assertThat(accuracy).isStrictlyBetween(0.0, 1.0); + } + + private List trainingDocuments() throws Exception + { + return asList( // + createLabeledCas("I like wine.", "positive"), + createLabeledCas("I like cats.", "positive"), + createLabeledCas("I like trees.", "positive"), + createLabeledCas("I like dogs.", "positive"), + createLabeledCas("I like sausages.", "positive"), + createLabeledCas("I hate pain.", "negative"), + createLabeledCas("I hate eggs.", "negative"), + createLabeledCas("I hate farts.", "negative"), + createLabeledCas("I hate jelly.", "negative"), + createLabeledCas("I hate girkins.", "negative")); + } + + private CAS makePredictionCas(String aText, AnnotationFeature aFeature) + throws ResourceInitializationException + { + RecommenderTypeSystemUtils.addPredictionFeaturesToTypeSystem(tsd, asList(aFeature)); + var predictionCas = CasFactory.createCas(tsd); + predictionCas.setDocumentText(aText); + SegmentationUtils.splitSentences(predictionCas); + SegmentationUtils.tokenize(predictionCas); + return predictionCas; + } + + private CAS createLabeledCas(String aText, String aLabel) throws Exception + { + var cas = CasFactory.createCas(tsd); + cas.setDocumentText(aText); + + buildFS(cas, feature.getLayer().getName()) // + .withFeature(feature.getName(), aLabel) // + .buildAndAddToIndexes(); + + SegmentationUtils.splitSentences(cas); + SegmentationUtils.tokenize(cas); + + return cas; + } +} diff --git a/inception/inception-imls-opennlp/src/test/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatRecommenderTest.java b/inception/inception-imls-opennlp/src/test/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatRecommenderTest.java index e299e72daad..79b43de5c00 100644 --- a/inception/inception-imls-opennlp/src/test/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatRecommenderTest.java +++ b/inception/inception-imls-opennlp/src/test/java/de/tudarmstadt/ukp/inception/recommendation/imls/opennlp/doccat/OpenNlpDoccatRecommenderTest.java @@ -28,16 +28,13 @@ import java.io.BufferedInputStream; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.apache.uima.UIMAException; -import org.apache.uima.analysis_engine.AnalysisEngine; import org.apache.uima.cas.CAS; import org.apache.uima.collection.CollectionException; -import org.apache.uima.collection.CollectionReader; import org.apache.uima.fit.factory.JCasFactory; import org.apache.uima.jcas.JCas; import org.dkpro.core.api.datasets.Dataset; @@ -53,8 +50,6 @@ import de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; import de.tudarmstadt.ukp.inception.annotation.storage.CasStorageSession; -import de.tudarmstadt.ukp.inception.recommendation.api.evaluation.DataSplitter; -import de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult; import de.tudarmstadt.ukp.inception.recommendation.api.evaluation.IncrementalSplitter; import de.tudarmstadt.ukp.inception.recommendation.api.evaluation.PercentageBasedSplitter; import de.tudarmstadt.ukp.inception.recommendation.api.model.Recommender; @@ -85,8 +80,8 @@ public void setUp() @Test public void thatTrainingWorks() throws Exception { - OpenNlpDoccatRecommender sut = new OpenNlpDoccatRecommender(recommender, traits); - List casList = loadArxivData(); + var sut = new OpenNlpDoccatRecommender(recommender, traits); + var casList = loadArxivData(); sut.train(context, casList); @@ -97,11 +92,11 @@ public void thatTrainingWorks() throws Exception @Test public void thatPredictionWorks() throws Exception { - OpenNlpDoccatRecommender sut = new OpenNlpDoccatRecommender(recommender, traits); - List casList = loadArxivData(); + var sut = new OpenNlpDoccatRecommender(recommender, traits); + var casList = loadArxivData(); - CAS cas = casList.get(0); - try (CasStorageSession session = CasStorageSession.open()) { + var cas = casList.get(0); + try (var session = CasStorageSession.open()) { session.add("testCas", EXCLUSIVE_WRITE_ACCESS, cas); RecommenderTestHelper.addScoreFeature(cas, NamedEntity.class, "value"); } @@ -110,7 +105,7 @@ public void thatPredictionWorks() throws Exception sut.predict(context, cas); - List predictions = getPredictions(cas, NamedEntity.class); + var predictions = getPredictions(cas, NamedEntity.class); assertThat(predictions).as("Predictions have been written to CAS").isNotEmpty(); } @@ -118,16 +113,16 @@ public void thatPredictionWorks() throws Exception @Test public void thatEvaluationWorks() throws Exception { - DataSplitter splitStrategy = new PercentageBasedSplitter(0.8, 10); - OpenNlpDoccatRecommender sut = new OpenNlpDoccatRecommender(recommender, traits); - List casList = loadArxivData(); + var splitStrategy = new PercentageBasedSplitter(0.8, 10); + var sut = new OpenNlpDoccatRecommender(recommender, traits); + var casList = loadArxivData(); - EvaluationResult result = sut.evaluate(casList, splitStrategy); + var result = sut.evaluate(casList, splitStrategy); - double fscore = result.computeF1Score(); - double accuracy = result.computeAccuracyScore(); - double precision = result.computePrecisionScore(); - double recall = result.computeRecallScore(); + var fscore = result.computeF1Score(); + var accuracy = result.computeAccuracyScore(); + var precision = result.computePrecisionScore(); + var recall = result.computeRecallScore(); System.out.printf("F1-Score: %f%n", fscore); System.out.printf("Accuracy: %f%n", accuracy); @@ -143,15 +138,15 @@ public void thatEvaluationWorks() throws Exception @Test public void thatIncrementalNerEvaluationWorks() throws Exception { - IncrementalSplitter splitStrategy = new IncrementalSplitter(0.8, 250, 10); - OpenNlpDoccatRecommender sut = new OpenNlpDoccatRecommender(recommender, traits); - List casList = loadArxivData(); + var splitStrategy = new IncrementalSplitter(0.8, 250, 10); + var sut = new OpenNlpDoccatRecommender(recommender, traits); + var casList = loadArxivData(); int i = 0; while (splitStrategy.hasNext() && i < 3) { splitStrategy.next(); - double score = sut.evaluate(casList, splitStrategy).computeF1Score(); + var score = sut.evaluate(casList, splitStrategy).computeF1Score(); System.out.printf("Score: %f%n", score); @@ -163,22 +158,24 @@ public void thatIncrementalNerEvaluationWorks() throws Exception private List loadArxivData() throws IOException, UIMAException { - Dataset ds = loader.load("sentence-classification-en"); + var ds = loader.load("sentence-classification-en"); return loadData(ds, Arrays.stream(ds.getDataFiles()) .filter(file -> file.getName().contains("arxiv")).toArray(File[]::new)); } private List loadData(Dataset ds, File... files) throws UIMAException, IOException { - CollectionReader reader = createReader(Reader.class, Reader.PARAM_PATTERNS, files, + var reader = createReader(Reader.class, // + Reader.PARAM_PATTERNS, files, // Reader.PARAM_LANGUAGE, ds.getLanguage()); - AnalysisEngine segmenter = createEngine(BreakIteratorSegmenter.class, + var segmenter = createEngine( // + BreakIteratorSegmenter.class, // BreakIteratorSegmenter.PARAM_WRITE_SENTENCE, false); - List casList = new ArrayList<>(); + var casList = new ArrayList(); while (reader.hasNext()) { - JCas cas = JCasFactory.createJCas(); + var cas = JCasFactory.createJCas(); reader.getNext(cas.getCas()); segmenter.process(cas); casList.add(cas.getCas()); @@ -188,13 +185,13 @@ private List loadData(Dataset ds, File... files) throws UIMAException, IOEx private static Recommender buildRecommender() { - AnnotationLayer layer = new AnnotationLayer(); + var layer = new AnnotationLayer(); layer.setName(NamedEntity.class.getName()); - AnnotationFeature feature = new AnnotationFeature(); + var feature = new AnnotationFeature(); feature.setName("value"); - Recommender recommender = new Recommender(); + var recommender = new Recommender(); recommender.setLayer(layer); recommender.setFeature(feature); @@ -207,23 +204,23 @@ public static class Reader @Override public void getNext(JCas aJCas) throws IOException, CollectionException { - Resource res = nextFile(); + var res = nextFile(); initCas(aJCas, res); - StringBuilder text = new StringBuilder(); + var text = new StringBuilder(); - try (InputStream is = new BufferedInputStream( + try (var is = new BufferedInputStream( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()))) { try (var i = lineIterator(is, "UTF-8")) { while (i.hasNext()) { - String line = i.next(); + var line = i.next(); if (line.startsWith("#")) { continue; } - String[] fields = line.split("\\s", 2); + var fields = line.split("\\s", 2); if (text.length() > 0) { text.append("\n"); @@ -232,7 +229,7 @@ public void getNext(JCas aJCas) throws IOException, CollectionException int sentenceBegin = text.length(); text.append(fields[1]); - NamedEntity ne = new NamedEntity(aJCas, sentenceBegin, text.length()); + var ne = new NamedEntity(aJCas, sentenceBegin, text.length()); ne.setValue(fields[0]); ne.addToIndexes(); diff --git a/inception/inception-imls-stringmatch/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/stringmatch/relation/StringMatchingRelationRecommender.java b/inception/inception-imls-stringmatch/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/stringmatch/relation/StringMatchingRelationRecommender.java index 6854aa38d16..a3479b751b5 100644 --- a/inception/inception-imls-stringmatch/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/stringmatch/relation/StringMatchingRelationRecommender.java +++ b/inception/inception-imls-stringmatch/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/stringmatch/relation/StringMatchingRelationRecommender.java @@ -17,10 +17,10 @@ */ package de.tudarmstadt.ukp.inception.recommendation.imls.stringmatch.relation; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectOverlapping; import static de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult.toEvaluationResult; import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.FEAT_REL_SOURCE; import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.FEAT_REL_TARGET; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectOverlapping; import static java.util.function.Function.identity; import static java.util.stream.Collectors.counting; import static java.util.stream.Collectors.groupingBy; diff --git a/inception/inception-imls-stringmatch/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/stringmatch/span/StringMatchingRecommender.java b/inception/inception-imls-stringmatch/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/stringmatch/span/StringMatchingRecommender.java index 978b4960408..e2d569dea22 100644 --- a/inception/inception-imls-stringmatch/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/stringmatch/span/StringMatchingRecommender.java +++ b/inception/inception-imls-stringmatch/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/stringmatch/span/StringMatchingRecommender.java @@ -17,9 +17,9 @@ */ package de.tudarmstadt.ukp.inception.recommendation.imls.stringmatch.span; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectOverlapping; import static de.tudarmstadt.ukp.clarin.webanno.model.AnchoringMode.CHARACTERS; import static de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult.toEvaluationResult; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectOverlapping; import static java.util.Arrays.asList; import static java.util.Comparator.comparingInt; import static org.apache.commons.lang3.StringUtils.isBlank; diff --git a/inception/inception-kb-fact-linking/src/main/java/de/tudarmstadt/ukp/inception/kb/factlinking/feature/FactLinkingServiceImpl.java b/inception/inception-kb-fact-linking/src/main/java/de/tudarmstadt/ukp/inception/kb/factlinking/feature/FactLinkingServiceImpl.java index cf451b34ec6..2b02cb9699a 100644 --- a/inception/inception-kb-fact-linking/src/main/java/de/tudarmstadt/ukp/inception/kb/factlinking/feature/FactLinkingServiceImpl.java +++ b/inception/inception-kb-fact-linking/src/main/java/de/tudarmstadt/ukp/inception/kb/factlinking/feature/FactLinkingServiceImpl.java @@ -30,7 +30,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer; import de.tudarmstadt.ukp.clarin.webanno.model.Project; @@ -46,6 +45,7 @@ import de.tudarmstadt.ukp.inception.schema.api.feature.FeatureSupport; import de.tudarmstadt.ukp.inception.schema.api.feature.FeatureSupportRegistry; import de.tudarmstadt.ukp.inception.support.uima.ICasUtil; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; /** *

diff --git a/inception/inception-kb-fact-linking/src/main/java/de/tudarmstadt/ukp/inception/kb/factlinking/feature/SubjectObjectFeatureEditor.java b/inception/inception-kb-fact-linking/src/main/java/de/tudarmstadt/ukp/inception/kb/factlinking/feature/SubjectObjectFeatureEditor.java index fc716dc0097..d5b9fe647c6 100644 --- a/inception/inception-kb-fact-linking/src/main/java/de/tudarmstadt/ukp/inception/kb/factlinking/feature/SubjectObjectFeatureEditor.java +++ b/inception/inception-kb-fact-linking/src/main/java/de/tudarmstadt/ukp/inception/kb/factlinking/feature/SubjectObjectFeatureEditor.java @@ -55,7 +55,6 @@ import com.googlecode.wicket.jquery.core.template.IJQueryTemplate; import com.googlecode.wicket.kendo.ui.form.autocomplete.AutoCompleteTextField; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer; import de.tudarmstadt.ukp.clarin.webanno.model.Project; @@ -79,6 +78,7 @@ import de.tudarmstadt.ukp.inception.support.lambda.LambdaAjaxLink; import de.tudarmstadt.ukp.inception.support.lambda.LambdaModelAdapter; import de.tudarmstadt.ukp.inception.support.uima.ICasUtil; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; @Deprecated public class SubjectObjectFeatureEditor diff --git a/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/sidebar/DocumentMetadataAnnotationSelectionPanel.java b/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/sidebar/DocumentMetadataAnnotationSelectionPanel.java index d6e06550658..57ba0be20b3 100644 --- a/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/sidebar/DocumentMetadataAnnotationSelectionPanel.java +++ b/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/sidebar/DocumentMetadataAnnotationSelectionPanel.java @@ -21,6 +21,8 @@ import static de.tudarmstadt.ukp.inception.support.lambda.LambdaBehavior.enabledWhen; import static de.tudarmstadt.ukp.inception.support.lambda.LambdaBehavior.visibleWhen; import static java.util.Collections.emptyList; +import static java.util.function.Function.identity; +import static java.util.stream.Collectors.toMap; import java.io.IOException; import java.io.Serializable; @@ -51,6 +53,7 @@ import de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase; import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasProvider; +import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer; import de.tudarmstadt.ukp.clarin.webanno.model.Project; import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument; @@ -59,10 +62,12 @@ import de.tudarmstadt.ukp.inception.annotation.events.FeatureValueUpdatedEvent; import de.tudarmstadt.ukp.inception.editor.action.AnnotationActionHandler; import de.tudarmstadt.ukp.inception.recommendation.api.RecommendationService; +import de.tudarmstadt.ukp.inception.recommendation.api.model.MetadataSuggestion; import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState; import de.tudarmstadt.ukp.inception.rendering.vmodel.VID; import de.tudarmstadt.ukp.inception.schema.api.AnnotationSchemaService; import de.tudarmstadt.ukp.inception.schema.api.adapter.AnnotationException; +import de.tudarmstadt.ukp.inception.schema.api.feature.FeatureSupportRegistry; import de.tudarmstadt.ukp.inception.schema.api.feature.TypeUtil; import de.tudarmstadt.ukp.inception.schema.api.layer.LayerSupport; import de.tudarmstadt.ukp.inception.schema.api.layer.LayerSupportRegistry; @@ -92,6 +97,7 @@ public class DocumentMetadataAnnotationSelectionPanel private static final String CID_DELETE = "delete"; private @SpringBean LayerSupportRegistry layerSupportRegistry; + private @SpringBean FeatureSupportRegistry fsRegistry; private @SpringBean AnnotationSchemaService annotationService; private @SpringBean RecommendationService recommendationService; @@ -357,7 +363,11 @@ private List listAnnotations() var items = new ArrayList(); for (var layer : listMetadataLayers()) { + // Bulk-load all the features of this layer to avoid having to do repeated DB accesses + // later var features = annotationService.listSupportedFeatures(layer); + var featuresIndex = features.stream() + .collect(toMap(AnnotationFeature::getName, identity())); var adapter = annotationService.getAdapter(layer); LayerSupport layerSupport = layerSupportRegistry.getLayerSupport(layer); var renderer = layerSupport.createRenderer(layer, @@ -369,11 +379,24 @@ private List listAnnotations() var labelText = TypeUtil.getUiLabelText(renderedFeatures); items.add(new AnnotationListItem(VID.of(fs), labelText, layer, singleton)); } - } - var predictions = recommendationService.getPredictions(user.getObject(), getModelObject()); - if (predictions != null) { - predictions.getPredictionsByDocument(sourceDocument.getObject().getName()); + var predictions = recommendationService.getPredictions(user.getObject(), + getModelObject()); + if (predictions != null) { + for (var suggestion : predictions + .getPredictionsByDocument(sourceDocument.getObject().getName())) { + if (suggestion instanceof MetadataSuggestion metadataSuggestion) { + var feature = featuresIndex.get(suggestion.getFeature()); + + // Retrieve the UI display label for the given feature value + var featureSupport = fsRegistry.findExtension(feature).orElseThrow(); + var annotation = featureSupport.renderFeatureValue(feature, + suggestion.getLabel()); + items.add(new AnnotationListItem(suggestion.getVID(), annotation, layer, + singleton)); + } + } + } } return items; diff --git a/inception/inception-pdf-editor/src/main/java/de/tudarmstadt/ukp/inception/pdfeditor/PdfAnnotationEditor.java b/inception/inception-pdf-editor/src/main/java/de/tudarmstadt/ukp/inception/pdfeditor/PdfAnnotationEditor.java index ef1ff787724..40e802df021 100644 --- a/inception/inception-pdf-editor/src/main/java/de/tudarmstadt/ukp/inception/pdfeditor/PdfAnnotationEditor.java +++ b/inception/inception-pdf-editor/src/main/java/de/tudarmstadt/ukp/inception/pdfeditor/PdfAnnotationEditor.java @@ -17,10 +17,10 @@ */ package de.tudarmstadt.ukp.inception.pdfeditor; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectSentenceAt; import static de.tudarmstadt.ukp.inception.pdfeditor.pdfanno.render.PdfAnnoSerializer.convertToDocumentOffset; import static de.tudarmstadt.ukp.inception.pdfeditor.pdfanno.render.PdfAnnoSerializer.convertToDocumentOffsets; import static de.tudarmstadt.ukp.inception.rendering.vmodel.VID.NONE_ID; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectSentenceAt; import static de.tudarmstadt.ukp.inception.support.wicket.ServletContextUtils.referenceToUrl; import static java.lang.String.join; import static java.util.Arrays.asList; diff --git a/inception/inception-recommendation-api/src/test/java/de/tudarmstadt/ukp/inception/recommendation/api/model/PredictionsTest.java b/inception/inception-recommendation-api/src/test/java/de/tudarmstadt/ukp/inception/recommendation/api/model/PredictionsTest.java index bb7023c6705..c34b608b3aa 100644 --- a/inception/inception-recommendation-api/src/test/java/de/tudarmstadt/ukp/inception/recommendation/api/model/PredictionsTest.java +++ b/inception/inception-recommendation-api/src/test/java/de/tudarmstadt/ukp/inception/recommendation/api/model/PredictionsTest.java @@ -42,7 +42,7 @@ import de.tudarmstadt.ukp.clarin.webanno.security.model.User; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; -import de.tudarmstadt.ukp.inception.export.SegmentationUtils; +import de.tudarmstadt.ukp.inception.support.uima.SegmentationUtils; @ExtendWith(MockitoExtension.class) class PredictionsTest diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/render/RecommendationRelationRenderer.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/render/RecommendationRelationRenderer.java index 1fc6349f324..fe921e713ec 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/render/RecommendationRelationRenderer.java +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/render/RecommendationRelationRenderer.java @@ -17,8 +17,8 @@ */ package de.tudarmstadt.ukp.inception.recommendation.render; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getDocumentTitle; import static de.tudarmstadt.ukp.inception.annotation.storage.CasMetadataUtils.getSourceDocumentName; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.getDocumentTitle; import static java.util.function.Function.identity; import static java.util.stream.Collectors.toMap; import static org.apache.uima.fit.util.CasUtil.selectAt; diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/render/RecommendationSpanRenderer.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/render/RecommendationSpanRenderer.java index 69602bde33c..ad456f2469c 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/render/RecommendationSpanRenderer.java +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/render/RecommendationSpanRenderer.java @@ -17,7 +17,7 @@ */ package de.tudarmstadt.ukp.inception.recommendation.render; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getDocumentTitle; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.getDocumentTitle; import static java.util.function.Function.identity; import static java.util.stream.Collectors.toMap; 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 9407c06c0c4..587aef2c925 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 @@ -106,7 +106,6 @@ import org.springframework.transaction.annotation.Transactional; import de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocument; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocumentState; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature; @@ -178,6 +177,7 @@ import de.tudarmstadt.ukp.inception.support.logging.LogMessage; import de.tudarmstadt.ukp.inception.support.logging.LogMessageGroup; import de.tudarmstadt.ukp.inception.support.uima.ICasUtil; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; import de.tudarmstadt.ukp.inception.support.wicket.WicketExceptionUtil; /** diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommenderInfoPanel.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommenderInfoPanel.java index 773844a7354..7b6ae2366fe 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommenderInfoPanel.java +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommenderInfoPanel.java @@ -17,8 +17,8 @@ */ package de.tudarmstadt.ukp.inception.recommendation.sidebar; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getDocumentTitle; import static de.tudarmstadt.ukp.inception.support.lambda.LambdaBehavior.visibleWhen; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.getDocumentTitle; import static java.util.stream.Collectors.groupingBy; import static org.apache.commons.lang3.StringUtils.repeat; diff --git a/inception/inception-recommendation/src/test/java/de/tudarmstadt/ukp/inception/recommendation/service/SuggestionExtractionTest.java b/inception/inception-recommendation/src/test/java/de/tudarmstadt/ukp/inception/recommendation/service/SuggestionExtractionTest.java index 5190ab30d13..0910f991c3e 100644 --- a/inception/inception-recommendation/src/test/java/de/tudarmstadt/ukp/inception/recommendation/service/SuggestionExtractionTest.java +++ b/inception/inception-recommendation/src/test/java/de/tudarmstadt/ukp/inception/recommendation/service/SuggestionExtractionTest.java @@ -40,11 +40,11 @@ import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument; import de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity; import de.tudarmstadt.ukp.inception.annotation.layer.span.SpanLayerSupport; -import de.tudarmstadt.ukp.inception.export.SegmentationUtils; import de.tudarmstadt.ukp.inception.recommendation.api.RecommenderTypeSystemUtils; import de.tudarmstadt.ukp.inception.recommendation.api.model.MetadataSuggestion; import de.tudarmstadt.ukp.inception.recommendation.api.model.Recommender; import de.tudarmstadt.ukp.inception.recommendation.api.model.SpanSuggestion; +import de.tudarmstadt.ukp.inception.support.uima.SegmentationUtils; import de.tudarmstadt.ukp.inception.ui.core.docanno.layer.DocumentMetadataLayerSupport; class SuggestionExtractionTest diff --git a/inception/inception-remote/src/main/java/de/tudarmstadt/ukp/clarin/webanno/webapp/remoteapi/aero/AeroRemoteApiController.java b/inception/inception-remote/src/main/java/de/tudarmstadt/ukp/clarin/webanno/webapp/remoteapi/aero/AeroRemoteApiController.java index f0b97e88f36..8e279d0213a 100644 --- a/inception/inception-remote/src/main/java/de/tudarmstadt/ukp/clarin/webanno/webapp/remoteapi/aero/AeroRemoteApiController.java +++ b/inception/inception-remote/src/main/java/de/tudarmstadt/ukp/clarin/webanno/webapp/remoteapi/aero/AeroRemoteApiController.java @@ -17,13 +17,13 @@ */ package de.tudarmstadt.ukp.clarin.webanno.webapp.remoteapi.aero; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectSentences; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectTokens; import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.ANNOTATOR; import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.CURATOR; import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.MANAGER; import static de.tudarmstadt.ukp.clarin.webanno.webapp.remoteapi.aero.model.RMessageLevel.ERROR; import static de.tudarmstadt.ukp.clarin.webanno.webapp.remoteapi.aero.model.RMessageLevel.INFO; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectSentences; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectTokens; import static java.io.File.createTempFile; import static java.util.stream.Collectors.toList; import static org.apache.commons.io.FilenameUtils.getExtension; diff --git a/inception/inception-schema/src/main/java/de/tudarmstadt/ukp/inception/schema/service/AnnotationSchemaServiceImpl.java b/inception/inception-schema/src/main/java/de/tudarmstadt/ukp/inception/schema/service/AnnotationSchemaServiceImpl.java index cedd8fe4966..99e3227af45 100644 --- a/inception/inception-schema/src/main/java/de/tudarmstadt/ukp/inception/schema/service/AnnotationSchemaServiceImpl.java +++ b/inception/inception-schema/src/main/java/de/tudarmstadt/ukp/inception/schema/service/AnnotationSchemaServiceImpl.java @@ -17,9 +17,6 @@ */ package de.tudarmstadt.ukp.inception.schema.service; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getRealCas; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.isNativeUimaType; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.isSame; import static de.tudarmstadt.ukp.clarin.webanno.model.LinkMode.WITH_ROLE; import static de.tudarmstadt.ukp.clarin.webanno.model.MultiValueMode.ARRAY; import static de.tudarmstadt.ukp.inception.project.api.ProjectService.withProjectLogger; @@ -28,6 +25,9 @@ import static de.tudarmstadt.ukp.inception.schema.api.AttachedAnnotation.Direction.OUTGOING; import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.RELATION_TYPE; import static de.tudarmstadt.ukp.inception.support.uima.ICasUtil.selectByAddr; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.getRealCas; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.isNativeUimaType; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.isSame; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.Objects.isNull; diff --git a/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/SearchServiceImpl.java b/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/SearchServiceImpl.java index 23da9a0ef66..6453181fa4b 100644 --- a/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/SearchServiceImpl.java +++ b/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/SearchServiceImpl.java @@ -17,11 +17,11 @@ */ package de.tudarmstadt.ukp.inception.search; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.casToByteArray; import static de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasAccessMode.UNMANAGED_ACCESS; import static de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasAccessMode.UNMANAGED_NON_INITIALIZING_ACCESS; import static de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasUpgradeMode.NO_CAS_UPGRADE; import static de.tudarmstadt.ukp.inception.search.model.AnnotationSearchState.KEY_SEARCH_STATE; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.casToByteArray; import static java.lang.System.currentTimeMillis; import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.stream.Collectors.toList; diff --git a/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/scheduling/tasks/IndexAnnotationDocumentTask.java b/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/scheduling/tasks/IndexAnnotationDocumentTask.java index 71a37c30039..293c1e78e8c 100644 --- a/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/scheduling/tasks/IndexAnnotationDocumentTask.java +++ b/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/scheduling/tasks/IndexAnnotationDocumentTask.java @@ -34,7 +34,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocument; import de.tudarmstadt.ukp.inception.annotation.storage.CasStorageSession; import de.tudarmstadt.ukp.inception.documents.api.DocumentService; @@ -42,6 +41,7 @@ import de.tudarmstadt.ukp.inception.scheduling.Task; import de.tudarmstadt.ukp.inception.search.SearchService; import de.tudarmstadt.ukp.inception.search.model.Progress; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; /** * (Re)indexes the annotation document for a specific user. diff --git a/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/scheduling/tasks/IndexSourceDocumentTask.java b/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/scheduling/tasks/IndexSourceDocumentTask.java index f343e107a65..465c39476e8 100644 --- a/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/scheduling/tasks/IndexSourceDocumentTask.java +++ b/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/scheduling/tasks/IndexSourceDocumentTask.java @@ -34,7 +34,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument; import de.tudarmstadt.ukp.inception.annotation.storage.CasStorageSession; import de.tudarmstadt.ukp.inception.documents.api.DocumentService; @@ -42,6 +41,7 @@ import de.tudarmstadt.ukp.inception.scheduling.Task; import de.tudarmstadt.ukp.inception.search.SearchService; import de.tudarmstadt.ukp.inception.search.model.Progress; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; /** * Document indexer task. Indexes the given document in a project diff --git a/inception/inception-search-mtas/src/main/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasUimaParser.java b/inception/inception-search-mtas/src/main/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasUimaParser.java index e2a1351d429..6e70b104347 100644 --- a/inception/inception-search-mtas/src/main/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasUimaParser.java +++ b/inception/inception-search-mtas/src/main/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasUimaParser.java @@ -17,12 +17,12 @@ */ package de.tudarmstadt.ukp.inception.search.index.mtas; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getRealCas; import static de.tudarmstadt.ukp.inception.search.FeatureIndexingSupport.SPECIAL_SEP; import static de.tudarmstadt.ukp.inception.search.index.mtas.MtasUtils.charsToBytes; import static de.tudarmstadt.ukp.inception.search.index.mtas.MtasUtils.encodeFSAddress; import static de.tudarmstadt.ukp.inception.search.model.AnnotationSearchState.KEY_SEARCH_STATE; import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.RELATION_TYPE; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.getRealCas; import static java.lang.invoke.MethodHandles.lookup; import static mtas.analysis.util.MtasTokenizerFactory.ARGUMENT_PARSER_ARGS; import static org.apache.commons.io.IOUtils.toCharArray; @@ -56,7 +56,6 @@ import com.github.openjson.JSONObject; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer; import de.tudarmstadt.ukp.clarin.webanno.model.Project; @@ -72,6 +71,7 @@ import de.tudarmstadt.ukp.inception.search.model.BulkIndexingContext; import de.tudarmstadt.ukp.inception.support.spring.ApplicationContextProvider; import de.tudarmstadt.ukp.inception.support.uima.ICasUtil; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; import mtas.analysis.parser.MtasParser; import mtas.analysis.token.MtasToken; import mtas.analysis.token.MtasTokenCollection; diff --git a/inception/inception-search-mtas/src/test/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasUimaParserLuceneTest.java b/inception/inception-search-mtas/src/test/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasUimaParserLuceneTest.java index 559ff808699..8c99c0b237e 100644 --- a/inception/inception-search-mtas/src/test/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasUimaParserLuceneTest.java +++ b/inception/inception-search-mtas/src/test/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasUimaParserLuceneTest.java @@ -66,10 +66,10 @@ import org.junit.jupiter.api.io.TempDir; import org.xml.sax.SAXException; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; import mtas.analysis.token.MtasTokenString; import mtas.analysis.util.MtasTokenizerFactory; import mtas.codec.MtasCodec; diff --git a/inception/inception-support/pom.xml b/inception/inception-support/pom.xml index 360b57a76f3..bfbb0c9c74b 100644 --- a/inception/inception-support/pom.xml +++ b/inception/inception-support/pom.xml @@ -39,6 +39,11 @@ uimafit-core + + org.dkpro.core + dkpro-core-api-segmentation-asl + + commons-io commons-io @@ -51,6 +56,10 @@ org.apache.commons commons-collections4 + + it.unimi.dsi + fastutil + com.github.rjeschke diff --git a/inception/inception-export/src/main/java/de/tudarmstadt/ukp/inception/export/SegmentationUtils.java b/inception/inception-support/src/main/java/de/tudarmstadt/ukp/inception/support/uima/SegmentationUtils.java similarity index 93% rename from inception/inception-export/src/main/java/de/tudarmstadt/ukp/inception/export/SegmentationUtils.java rename to inception/inception-support/src/main/java/de/tudarmstadt/ukp/inception/support/uima/SegmentationUtils.java index 35e5864fca0..7ed17356b9c 100644 --- a/inception/inception-export/src/main/java/de/tudarmstadt/ukp/inception/export/SegmentationUtils.java +++ b/inception/inception-support/src/main/java/de/tudarmstadt/ukp/inception/support/uima/SegmentationUtils.java @@ -15,11 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package de.tudarmstadt.ukp.inception.export; +package de.tudarmstadt.ukp.inception.support.uima; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.createSentence; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.createToken; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectSentences; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.createSentence; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.createToken; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.selectSentences; import java.text.BreakIterator; import java.util.Locale; diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/util/ThreadLockingInvocationHandler.java b/inception/inception-support/src/main/java/de/tudarmstadt/ukp/inception/support/uima/ThreadLockingInvocationHandler.java similarity index 97% rename from inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/util/ThreadLockingInvocationHandler.java rename to inception/inception-support/src/main/java/de/tudarmstadt/ukp/inception/support/uima/ThreadLockingInvocationHandler.java index 9c5aeda07c6..eb3def5a414 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/util/ThreadLockingInvocationHandler.java +++ b/inception/inception-support/src/main/java/de/tudarmstadt/ukp/inception/support/uima/ThreadLockingInvocationHandler.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package de.tudarmstadt.ukp.clarin.webanno.api.annotation.util; +package de.tudarmstadt.ukp.inception.support.uima; import static java.util.Arrays.asList; import static java.util.stream.Collectors.joining; diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/util/WebAnnoCasUtil.java b/inception/inception-support/src/main/java/de/tudarmstadt/ukp/inception/support/uima/WebAnnoCasUtil.java similarity index 99% rename from inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/util/WebAnnoCasUtil.java rename to inception/inception-support/src/main/java/de/tudarmstadt/ukp/inception/support/uima/WebAnnoCasUtil.java index 6abd73ad23b..af21c693acd 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/util/WebAnnoCasUtil.java +++ b/inception/inception-support/src/main/java/de/tudarmstadt/ukp/inception/support/uima/WebAnnoCasUtil.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package de.tudarmstadt.ukp.clarin.webanno.api.annotation.util; +package de.tudarmstadt.ukp.inception.support.uima; import static java.io.ObjectInputFilter.Config.createFilter; import static java.lang.String.join; @@ -66,7 +66,6 @@ import de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; -import de.tudarmstadt.ukp.inception.support.uima.ICasUtil; /** * Contain Methods for updating CAS Objects directed from brat UI, different utility methods to diff --git a/inception/inception-testing/src/main/java/de/tudarmstadt/ukp/inception/support/test/recommendation/RecommenderTestHelper.java b/inception/inception-testing/src/main/java/de/tudarmstadt/ukp/inception/support/test/recommendation/RecommenderTestHelper.java index 0beae585823..63901646473 100644 --- a/inception/inception-testing/src/main/java/de/tudarmstadt/ukp/inception/support/test/recommendation/RecommenderTestHelper.java +++ b/inception/inception-testing/src/main/java/de/tudarmstadt/ukp/inception/support/test/recommendation/RecommenderTestHelper.java @@ -32,6 +32,7 @@ import org.apache.uima.UIMAException; import org.apache.uima.cas.CAS; import org.apache.uima.cas.Feature; +import org.apache.uima.cas.FeatureStructure; import org.apache.uima.cas.Type; import org.apache.uima.cas.text.AnnotationFS; import org.apache.uima.fit.util.CasUtil; @@ -103,4 +104,13 @@ public static List getPredictions(CAS aCas, String aTypeName) thro .collect(Collectors.toList()); } + public static List getPredictionFSes(CAS aCas, String aTypeName) + throws Exception + { + Type type = CasUtil.getType(aCas, aTypeName); + Feature feature = type.getFeatureByBaseName(FEATURE_NAME_IS_PREDICTION); + + return aCas.select(type).filter(fs -> fs.getBooleanValue(feature)) + .collect(Collectors.toList()); + } } diff --git a/inception/inception-ui-agreement/src/main/java/de/tudarmstadt/ukp/inception/ui/agreement/page/AgreementPage.java b/inception/inception-ui-agreement/src/main/java/de/tudarmstadt/ukp/inception/ui/agreement/page/AgreementPage.java index dd2e3a9de4b..50cadc969cd 100644 --- a/inception/inception-ui-agreement/src/main/java/de/tudarmstadt/ukp/inception/ui/agreement/page/AgreementPage.java +++ b/inception/inception-ui-agreement/src/main/java/de/tudarmstadt/ukp/inception/ui/agreement/page/AgreementPage.java @@ -63,7 +63,6 @@ import de.tudarmstadt.ukp.clarin.webanno.agreement.measures.AgreementMeasureSupport; import de.tudarmstadt.ukp.clarin.webanno.agreement.measures.AgreementMeasureSupportRegistry; import de.tudarmstadt.ukp.clarin.webanno.agreement.measures.DefaultAgreementTraits; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocument; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature; import de.tudarmstadt.ukp.clarin.webanno.model.Project; @@ -80,6 +79,7 @@ import de.tudarmstadt.ukp.inception.support.lambda.LambdaAjaxButton; import de.tudarmstadt.ukp.inception.support.lambda.LambdaAjaxFormComponentUpdatingBehavior; import de.tudarmstadt.ukp.inception.support.lambda.LambdaChoiceRenderer; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; @MountPath(NS_PROJECT + "/${" + PAGE_PARAM_PROJECT + "}/agreement") public class AgreementPage 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 db9558c3988..cba393f5d49 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 @@ -17,14 +17,14 @@ */ package de.tudarmstadt.ukp.clarin.webanno.ui.annotation.detail; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getSentenceNumber; -import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.isSame; import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.COREFERENCE_RELATION_FEATURE; import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.COREFERENCE_TYPE_FEATURE; import static de.tudarmstadt.ukp.inception.support.lambda.LambdaBehavior.visibleWhen; import static de.tudarmstadt.ukp.inception.support.uima.ICasUtil.getAddr; import static de.tudarmstadt.ukp.inception.support.uima.ICasUtil.selectAnnotationByAddr; import static de.tudarmstadt.ukp.inception.support.uima.ICasUtil.selectFsByAddr; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.getSentenceNumber; +import static de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil.isSame; import static java.util.Arrays.asList; import static org.apache.uima.fit.util.CasUtil.selectAt; import static wicket.contrib.input.events.EventType.click; @@ -78,7 +78,6 @@ import de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.IllegalPlacementException; import de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.constraints.evaluator.PossibleValue; import de.tudarmstadt.ukp.clarin.webanno.constraints.evaluator.RulesIndicator; import de.tudarmstadt.ukp.clarin.webanno.constraints.evaluator.ValuesGenerator; @@ -111,6 +110,7 @@ import de.tudarmstadt.ukp.inception.support.lambda.LambdaAjaxLink; import de.tudarmstadt.ukp.inception.support.lambda.LambdaBehavior; import de.tudarmstadt.ukp.inception.support.uima.ICasUtil; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; import de.tudarmstadt.ukp.inception.support.wicket.input.InputBehavior; import wicket.contrib.input.events.key.KeyType; diff --git a/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/search/ConceptFeatureIndexingSupport.java b/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/search/ConceptFeatureIndexingSupport.java index d6a4b3e4952..a1e03b25a91 100644 --- a/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/search/ConceptFeatureIndexingSupport.java +++ b/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/search/ConceptFeatureIndexingSupport.java @@ -27,7 +27,6 @@ import org.apache.uima.cas.text.AnnotationFS; import org.springframework.beans.factory.annotation.Autowired; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature; import de.tudarmstadt.ukp.inception.kb.KnowledgeBaseService; import de.tudarmstadt.ukp.inception.kb.graph.KBHandle; @@ -35,6 +34,7 @@ import de.tudarmstadt.ukp.inception.schema.api.feature.FeatureSupport; import de.tudarmstadt.ukp.inception.schema.api.feature.FeatureSupportRegistry; import de.tudarmstadt.ukp.inception.search.FeatureIndexingSupport; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; import de.tudarmstadt.ukp.inception.ui.kb.config.KnowledgeBaseServiceUIAutoConfiguration; /** diff --git a/inception/inception-versioning/src/main/java/de/tudarmstadt/ukp/inception/versioning/VersioningServiceImpl.java b/inception/inception-versioning/src/main/java/de/tudarmstadt/ukp/inception/versioning/VersioningServiceImpl.java index 50620fc4366..880d95fd05a 100644 --- a/inception/inception-versioning/src/main/java/de/tudarmstadt/ukp/inception/versioning/VersioningServiceImpl.java +++ b/inception/inception-versioning/src/main/java/de/tudarmstadt/ukp/inception/versioning/VersioningServiceImpl.java @@ -46,7 +46,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.FileSystemUtils; -import de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil; import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasStorageService; import de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayer; import de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayerReference; @@ -64,6 +63,7 @@ import de.tudarmstadt.ukp.inception.project.api.event.BeforeProjectRemovedEvent; import de.tudarmstadt.ukp.inception.schema.api.AnnotationSchemaService; import de.tudarmstadt.ukp.inception.support.json.JSONUtil; +import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; /** *