Search in sources :

Example 1 with PrimitiveUimaFeatureSupport

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.PrimitiveUimaFeatureSupport in project webanno by webanno.

the class CopyAnnotationTest method setup.

@Before
public void setup() {
    project = new Project();
    tokenLayer = new AnnotationLayer(Token.class.getName(), "Token", SPAN_TYPE, null, true);
    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);
    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);
    slotLayer = new AnnotationLayer(DiffUtils.HOST_TYPE, DiffUtils.HOST_TYPE, SPAN_TYPE, project, false);
    slotFeature = new AnnotationFeature();
    slotFeature.setName("links");
    slotFeature.setEnabled(true);
    slotFeature.setType(Token.class.getName());
    slotFeature.setLinkMode(LinkMode.WITH_ROLE);
    slotFeature.setUiName("f1");
    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);
    annotationSchemaService = new MockUp<AnnotationSchemaService>() {

        @Mock
        List<AnnotationFeature> listAnnotationFeature(AnnotationLayer type) {
            if (type.getName().equals(POS.class.getName())) {
                return asList(posFeature);
            }
            if (type.getName().equals(DiffUtils.HOST_TYPE)) {
                return asList(slotFeature, stringFeature);
            }
            throw new IllegalStateException("Unknown layer type: " + type.getName());
        }

        @Mock
        TypeAdapter getAdapter(AnnotationLayer aLayer) {
            return AnnotationSchemaServiceImpl.getAdapter(annotationSchemaService, featureSupportRegistry, null, aLayer);
        }
    }.getMockInstance();
    featureSupportRegistry = new FeatureSupportRegistryImpl(asList(new PrimitiveUimaFeatureSupport(), new SlotFeatureSupport()));
    featureSupportRegistry.init();
}
Also used : Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) SlotFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.SlotFeatureSupport) POS(de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS) FeatureSupportRegistryImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.FeatureSupportRegistryImpl) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token) MockUp(mockit.MockUp) PrimitiveUimaFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.PrimitiveUimaFeatureSupport) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) Before(org.junit.Before)

Aggregations

FeatureSupportRegistryImpl (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.FeatureSupportRegistryImpl)1 PrimitiveUimaFeatureSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.PrimitiveUimaFeatureSupport)1 SlotFeatureSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.SlotFeatureSupport)1 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)1 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)1 Project (de.tudarmstadt.ukp.clarin.webanno.model.Project)1 POS (de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS)1 Token (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)1 MockUp (mockit.MockUp)1 Before (org.junit.Before)1