Search in sources :

Example 1 with LayerBehaviorRegistryImpl

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerBehaviorRegistryImpl in project webanno by webanno.

the class AgreementMeasureTestSuite_ImplBase method setup.

@Before
public void setup() {
    initMocks(this);
    project = new Project();
    layers = new ArrayList<>();
    features = new ArrayList<>();
    FeatureSupportRegistryImpl featureSupportRegistry = new FeatureSupportRegistryImpl(asList(new StringFeatureSupport(), new BooleanFeatureSupport(), new NumberFeatureSupport(), new SlotFeatureSupport(annotationService)));
    featureSupportRegistry.init();
    LayerBehaviorRegistryImpl layerBehaviorRegistry = new LayerBehaviorRegistryImpl(asList());
    layerBehaviorRegistry.init();
    LayerSupportRegistryImpl layerRegistry = new LayerSupportRegistryImpl(asList(new SpanLayerSupport(featureSupportRegistry, null, layerBehaviorRegistry), new RelationLayerSupport(featureSupportRegistry, null, layerBehaviorRegistry), new ChainLayerSupport(featureSupportRegistry, null, layerBehaviorRegistry)));
    layerRegistry.init();
    when(annotationService.listSupportedLayers(any())).thenReturn(layers);
    when(annotationService.listAnnotationLayer(any())).thenReturn(layers);
    when(annotationService.listSupportedFeatures(any(AnnotationLayer.class))).thenReturn(features);
    when(annotationService.listAnnotationFeature(any(AnnotationLayer.class))).thenReturn(features);
    when(annotationService.getAdapter(any(AnnotationLayer.class))).then(_call -> {
        AnnotationLayer l = _call.getArgument(0);
        return layerRegistry.getLayerSupport(l).createAdapter(l, () -> annotationService.listAnnotationFeature(l));
    });
}
Also used : SlotFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.SlotFeatureSupport) SpanLayerSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.SpanLayerSupport) NumberFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.NumberFeatureSupport) RelationLayerSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.RelationLayerSupport) BooleanFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.BooleanFeatureSupport) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) ChainLayerSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.ChainLayerSupport) FeatureSupportRegistryImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.FeatureSupportRegistryImpl) LayerSupportRegistryImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerSupportRegistryImpl) StringFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.StringFeatureSupport) LayerBehaviorRegistryImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerBehaviorRegistryImpl) Before(org.junit.Before)

Example 2 with LayerBehaviorRegistryImpl

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerBehaviorRegistryImpl in project webanno by webanno.

the class CasMergeTestBase method setup.

@Before
public void setup() throws Exception {
    initMocks(this);
    SpanDiffAdapter slotHostDiffAdapter = new SpanDiffAdapter(HOST_TYPE);
    slotHostDiffAdapter.addLinkFeature("links", "role", "target");
    diffAdapters = new ArrayList<>();
    diffAdapters.add(TOKEN_DIFF_ADAPTER);
    diffAdapters.add(SENTENCE_DIFF_ADAPTER);
    diffAdapters.add(POS_DIFF_ADAPTER);
    diffAdapters.add(NER_DIFF_ADAPTER);
    diffAdapters.add(DEPENDENCY_DIFF_ADAPTER);
    diffAdapters.add(MULTIVALREL_DIFF_ADAPTER);
    diffAdapters.add(MULTIVALSPAN_DIFF_ADAPTER);
    diffAdapters.add(slotHostDiffAdapter);
    project = new Project();
    document = new SourceDocument();
    document.setProject(project);
    document.setName("document");
    sentenceLayer = new AnnotationLayer(Sentence.class.getName(), "Sentence", SPAN_TYPE, null, true, CHARACTERS, NO_OVERLAP);
    tokenLayer = new AnnotationLayer(Token.class.getName(), "Token", SPAN_TYPE, null, true, CHARACTERS, NO_OVERLAP);
    tokenPosFeature = new AnnotationFeature();
    tokenPosFeature.setName("pos");
    tokenPosFeature.setEnabled(true);
    tokenPosFeature.setType(POS.class.getName());
    tokenPosFeature.setUiName("pos");
    tokenPosFeature.setLayer(tokenLayer);
    tokenPosFeature.setProject(project);
    tokenPosFeature.setVisible(true);
    posLayer = new AnnotationLayer(POS.class.getName(), "POS", SPAN_TYPE, project, true, SINGLE_TOKEN, NO_OVERLAP);
    posLayer.setAttachType(tokenLayer);
    posLayer.setAttachFeature(tokenPosFeature);
    posFeature = new AnnotationFeature();
    posFeature.setName("PosValue");
    posFeature.setEnabled(true);
    posFeature.setType(CAS.TYPE_NAME_STRING);
    posFeature.setUiName("PosValue");
    posFeature.setLayer(posLayer);
    posFeature.setProject(project);
    posFeature.setVisible(true);
    posCoarseFeature = new AnnotationFeature();
    posCoarseFeature.setName("coarseValue");
    posCoarseFeature.setEnabled(true);
    posCoarseFeature.setType(CAS.TYPE_NAME_STRING);
    posCoarseFeature.setUiName("coarseValue");
    posCoarseFeature.setLayer(posLayer);
    posCoarseFeature.setProject(project);
    posCoarseFeature.setVisible(true);
    neLayer = new AnnotationLayer(NamedEntity.class.getName(), "Named Entity", SPAN_TYPE, project, true, TOKENS, OVERLAP_ONLY);
    neFeature = new AnnotationFeature();
    neFeature.setName("value");
    neFeature.setEnabled(true);
    neFeature.setType(CAS.TYPE_NAME_STRING);
    neFeature.setUiName("value");
    neFeature.setLayer(neLayer);
    neFeature.setProject(project);
    neFeature.setVisible(true);
    neIdentifierFeature = new AnnotationFeature();
    neIdentifierFeature.setName("identifier");
    neIdentifierFeature.setEnabled(true);
    neIdentifierFeature.setType(CAS.TYPE_NAME_STRING);
    neIdentifierFeature.setUiName("identifier");
    neIdentifierFeature.setLayer(neLayer);
    neIdentifierFeature.setProject(project);
    neIdentifierFeature.setVisible(true);
    depLayer = new AnnotationLayer(Dependency.class.getName(), "Dependency", RELATION_TYPE, project, true, SINGLE_TOKEN, OVERLAP_ONLY);
    depLayer.setAttachType(tokenLayer);
    depLayer.setAttachFeature(tokenPosFeature);
    depFeature = new AnnotationFeature();
    depFeature.setName("DependencyType");
    depFeature.setEnabled(true);
    depFeature.setType(CAS.TYPE_NAME_STRING);
    depFeature.setUiName("Relation");
    depFeature.setLayer(depLayer);
    depFeature.setProject(project);
    depFeature.setVisible(true);
    depFlavorFeature = new AnnotationFeature();
    depFlavorFeature.setName("flavor");
    depFlavorFeature.setEnabled(true);
    depFlavorFeature.setType(CAS.TYPE_NAME_STRING);
    depFlavorFeature.setUiName("flavor");
    depFlavorFeature.setLayer(depLayer);
    depFlavorFeature.setProject(project);
    depFlavorFeature.setVisible(true);
    slotLayer = new AnnotationLayer(HOST_TYPE, HOST_TYPE, SPAN_TYPE, project, false, SINGLE_TOKEN, NO_OVERLAP);
    slotFeature = new AnnotationFeature();
    slotFeature.setName("links");
    slotFeature.setEnabled(true);
    slotFeature.setType(Token.class.getName());
    slotFeature.setMode(MultiValueMode.ARRAY);
    slotFeature.setLinkMode(LinkMode.WITH_ROLE);
    slotFeature.setLinkTypeName(CurationTestUtils.LINK_TYPE);
    slotFeature.setLinkTypeRoleFeatureName("role");
    slotFeature.setLinkTypeTargetFeatureName("target");
    slotFeature.setUiName("links");
    slotFeature.setLayer(slotLayer);
    slotFeature.setProject(project);
    slotFeature.setVisible(true);
    stringFeature = new AnnotationFeature();
    stringFeature.setName("f1");
    stringFeature.setEnabled(true);
    stringFeature.setType(CAS.TYPE_NAME_STRING);
    stringFeature.setUiName("f1");
    stringFeature.setLayer(slotLayer);
    stringFeature.setProject(project);
    stringFeature.setVisible(true);
    multiValSpan = new AnnotationLayer("webanno.custom.Multivalspan", "Multivalspan", SPAN_TYPE, project, true, TOKENS, OVERLAP_ONLY);
    multiValSpanF1 = new AnnotationFeature();
    multiValSpanF1.setName("f1");
    multiValSpanF1.setEnabled(true);
    multiValSpanF1.setType(CAS.TYPE_NAME_STRING);
    multiValSpanF1.setUiName("f1");
    multiValSpanF1.setLayer(multiValSpan);
    multiValSpanF1.setProject(project);
    multiValSpanF1.setVisible(true);
    multiValSpanF2 = new AnnotationFeature();
    multiValSpanF2.setName("f2");
    multiValSpanF2.setEnabled(true);
    multiValSpanF2.setType(CAS.TYPE_NAME_STRING);
    multiValSpanF2.setUiName("f2");
    multiValSpanF2.setLayer(multiValSpan);
    multiValSpanF2.setProject(project);
    multiValSpanF2.setVisible(true);
    multiValRel = new AnnotationLayer("webanno.custom.Multivalrel", "Multivalrel", RELATION_TYPE, project, true, SINGLE_TOKEN, OVERLAP_ONLY);
    multiValRel.setAttachType(multiValSpan);
    multiValRelRel1 = new AnnotationFeature();
    multiValRelRel1.setName("rel1");
    multiValRelRel1.setEnabled(true);
    multiValRelRel1.setType(CAS.TYPE_NAME_STRING);
    multiValRelRel1.setUiName("rel1");
    multiValRelRel1.setLayer(multiValSpan);
    multiValRelRel1.setProject(project);
    multiValRelRel1.setVisible(true);
    multiValRelRel2 = new AnnotationFeature();
    multiValRelRel2.setName("rel2");
    multiValRelRel2.setEnabled(true);
    multiValRelRel2.setType(CAS.TYPE_NAME_STRING);
    multiValRelRel2.setUiName("rel2");
    multiValRelRel2.setLayer(multiValSpan);
    multiValRelRel2.setProject(project);
    multiValRelRel2.setVisible(true);
    when(schemaService.findLayer(any(Project.class), any(String.class))).thenAnswer(call -> {
        String type = call.getArgument(1, String.class);
        if (type.equals(Sentence.class.getName())) {
            return sentenceLayer;
        }
        if (type.equals(Token.class.getName())) {
            return tokenLayer;
        }
        if (type.equals(Dependency.class.getName())) {
            return depLayer;
        }
        if (type.equals(POS.class.getName())) {
            return posLayer;
        }
        if (type.equals(NamedEntity.class.getName())) {
            return neLayer;
        }
        if (type.equals(CurationTestUtils.HOST_TYPE)) {
            return slotLayer;
        }
        if (type.equals("webanno.custom.Multivalrel")) {
            return multiValRel;
        }
        if (type.equals("webanno.custom.Multivalspan")) {
            return multiValSpan;
        }
        throw new IllegalStateException("Unknown layer type: " + type);
    });
    when(schemaService.listSupportedFeatures((any(AnnotationLayer.class)))).thenAnswer(call -> schemaService.listAnnotationFeature(call.getArgument(0, AnnotationLayer.class)));
    when(schemaService.listAnnotationFeature(any(AnnotationLayer.class))).thenAnswer(call -> {
        AnnotationLayer type = call.getArgument(0, AnnotationLayer.class);
        if (type.getName().equals(Sentence.class.getName())) {
            return asList();
        }
        if (type.getName().equals(Token.class.getName())) {
            return asList();
        }
        if (type.getName().equals(Dependency.class.getName())) {
            return asList(depFeature, depFlavorFeature);
        }
        if (type.getName().equals(POS.class.getName())) {
            return asList(posFeature, posCoarseFeature);
        }
        if (type.getName().equals(NamedEntity.class.getName())) {
            return asList(neFeature, neIdentifierFeature);
        }
        if (type.getName().equals(HOST_TYPE)) {
            return asList(slotFeature, stringFeature);
        }
        if (type.getName().equals("webanno.custom.Multivalrel")) {
            return asList(multiValRelRel1, multiValRelRel2);
        }
        if (type.getName().equals("webanno.custom.Multivalspan")) {
            return asList(multiValSpanF1, multiValSpanF2);
        }
        throw new IllegalStateException("Unknown layer type: " + type.getName());
    });
    when(schemaService.getAdapter(any(AnnotationLayer.class))).thenAnswer(call -> {
        AnnotationLayer type = call.getArgument(0, AnnotationLayer.class);
        return layerSupportRegistry.getLayerSupport(type).createAdapter(type, () -> schemaService.listAnnotationFeature(type));
    });
    featureSupportRegistry = new FeatureSupportRegistryImpl(asList(new StringFeatureSupport(), new BooleanFeatureSupport(), new NumberFeatureSupport(), new SlotFeatureSupport(schemaService)));
    featureSupportRegistry.init();
    LayerBehaviorRegistryImpl layerBehaviorRegistry = new LayerBehaviorRegistryImpl(asList());
    layerBehaviorRegistry.init();
    layerSupportRegistry = new LayerSupportRegistryImpl(asList(new SpanLayerSupport(featureSupportRegistry, null, layerBehaviorRegistry), new RelationLayerSupport(featureSupportRegistry, null, layerBehaviorRegistry), new ChainLayerSupport(featureSupportRegistry, null, layerBehaviorRegistry)));
    layerSupportRegistry.init();
    sut = new CasMerge(schemaService);
}
Also used : SlotFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.SlotFeatureSupport) SpanLayerSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.SpanLayerSupport) NumberFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.NumberFeatureSupport) SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) RelationLayerSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.RelationLayerSupport) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token) BooleanFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.BooleanFeatureSupport) Dependency(de.tudarmstadt.ukp.dkpro.core.api.syntax.type.dependency.Dependency) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) NamedEntity(de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity) ChainLayerSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.ChainLayerSupport) POS(de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS) FeatureSupportRegistryImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.FeatureSupportRegistryImpl) LayerSupportRegistryImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerSupportRegistryImpl) Sentence(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence) StringFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.StringFeatureSupport) LayerBehaviorRegistryImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerBehaviorRegistryImpl) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) Before(org.junit.Before)

Example 3 with LayerBehaviorRegistryImpl

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerBehaviorRegistryImpl in project webanno by webanno.

the class BratRendererTest method setup.

@Before
public void setup() {
    initMocks(this);
    project = new Project();
    tokenLayer = new AnnotationLayer(Token.class.getName(), "Token", SPAN_TYPE, null, true, SINGLE_TOKEN, NO_OVERLAP);
    tokenLayer.setId(1l);
    tokenPosFeature = new AnnotationFeature();
    tokenPosFeature.setId(1l);
    tokenPosFeature.setName("pos");
    tokenPosFeature.setEnabled(true);
    tokenPosFeature.setType(POS.class.getName());
    tokenPosFeature.setUiName("pos");
    tokenPosFeature.setLayer(tokenLayer);
    tokenPosFeature.setProject(project);
    tokenPosFeature.setVisible(true);
    posLayer = new AnnotationLayer(POS.class.getName(), "POS", SPAN_TYPE, project, true, SINGLE_TOKEN, NO_OVERLAP);
    posLayer.setId(2l);
    posLayer.setAttachType(tokenLayer);
    posLayer.setAttachFeature(tokenPosFeature);
    posFeature = new AnnotationFeature();
    posFeature.setId(2l);
    posFeature.setName("PosValue");
    posFeature.setEnabled(true);
    posFeature.setType(CAS.TYPE_NAME_STRING);
    posFeature.setUiName("PosValue");
    posFeature.setLayer(posLayer);
    posFeature.setProject(project);
    posFeature.setVisible(true);
    FeatureSupportRegistryImpl featureSupportRegistry = new FeatureSupportRegistryImpl(asList(new StringFeatureSupport(), new BooleanFeatureSupport(), new NumberFeatureSupport(), new SlotFeatureSupport(schemaService)));
    featureSupportRegistry.init();
    LayerBehaviorRegistryImpl layerBehaviorRegistry = new LayerBehaviorRegistryImpl(asList());
    layerBehaviorRegistry.init();
    LayerSupportRegistryImpl layerRegistry = new LayerSupportRegistryImpl(asList(new SpanLayerSupport(featureSupportRegistry, null, layerBehaviorRegistry), new RelationLayerSupport(featureSupportRegistry, null, layerBehaviorRegistry), new ChainLayerSupport(featureSupportRegistry, null, layerBehaviorRegistry)));
    layerRegistry.init();
    when(schemaService.listSupportedLayers(any())).thenReturn(asList(posLayer));
    when(schemaService.listAnnotationLayer(any())).thenReturn(asList(posLayer));
    when(schemaService.listSupportedFeatures(any(Project.class))).thenReturn(asList(posFeature));
    when(schemaService.listAnnotationFeature(any(Project.class))).thenReturn(asList(posFeature));
    when(schemaService.getAdapter(any(AnnotationLayer.class))).then(_call -> {
        AnnotationLayer layer = _call.getArgument(0);
        return layerRegistry.getLayerSupport(layer).createAdapter(layer, () -> asList(posFeature));
    });
    preRenderer = new PreRendererImpl(layerRegistry, schemaService);
}
Also used : SlotFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.SlotFeatureSupport) SpanLayerSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.SpanLayerSupport) NumberFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.NumberFeatureSupport) RelationLayerSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.RelationLayerSupport) BooleanFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.BooleanFeatureSupport) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) ChainLayerSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.ChainLayerSupport) POS(de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS) FeatureSupportRegistryImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.FeatureSupportRegistryImpl) PreRendererImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.PreRendererImpl) LayerSupportRegistryImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerSupportRegistryImpl) StringFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.StringFeatureSupport) LayerBehaviorRegistryImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerBehaviorRegistryImpl) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) Before(org.junit.Before)

Aggregations

BooleanFeatureSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.BooleanFeatureSupport)3 FeatureSupportRegistryImpl (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.FeatureSupportRegistryImpl)3 NumberFeatureSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.NumberFeatureSupport)3 SlotFeatureSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.SlotFeatureSupport)3 StringFeatureSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.StringFeatureSupport)3 ChainLayerSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.ChainLayerSupport)3 LayerBehaviorRegistryImpl (de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerBehaviorRegistryImpl)3 LayerSupportRegistryImpl (de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerSupportRegistryImpl)3 RelationLayerSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.RelationLayerSupport)3 SpanLayerSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.SpanLayerSupport)3 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)3 Project (de.tudarmstadt.ukp.clarin.webanno.model.Project)3 Before (org.junit.Before)3 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)2 POS (de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS)2 PreRendererImpl (de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.PreRendererImpl)1 SpanDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter)1 SourceDocument (de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument)1 NamedEntity (de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity)1 Sentence (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)1