Search in sources :

Example 1 with DiffAdapter_ImplBase

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter_ImplBase in project webanno by webanno.

the class CasDiff method getDiffAdapters.

public static List<DiffAdapter> getDiffAdapters(AnnotationSchemaService schemaService, Iterable<AnnotationLayer> aLayers) {
    List<DiffAdapter> adapters = new ArrayList<>();
    nextLayer: for (AnnotationLayer layer : aLayers) {
        if (!layer.isEnabled()) {
            continue nextLayer;
        }
        Set<String> labelFeatures = new LinkedHashSet<>();
        nextFeature: for (AnnotationFeature f : schemaService.listSupportedFeatures(layer)) {
            if (!f.isEnabled()) {
                continue nextFeature;
            }
            // Link features are treated separately from primitive label features
            if (!NONE.equals(f.getLinkMode())) {
                continue nextFeature;
            }
            labelFeatures.add(f.getName());
        }
        DiffAdapter_ImplBase adapter;
        switch(layer.getType()) {
            case SPAN_TYPE:
                {
                    adapter = new SpanDiffAdapter(layer.getName(), labelFeatures);
                    break;
                }
            case RELATION_TYPE:
                {
                    RelationAdapter typeAdpt = (RelationAdapter) schemaService.getAdapter(layer);
                    adapter = new RelationDiffAdapter(layer.getName(), typeAdpt.getSourceFeatureName(), typeAdpt.getTargetFeatureName(), labelFeatures);
                    break;
                }
            default:
                LOG.debug("Curation for layer type [{}] not supported - ignoring", layer.getType());
                continue nextLayer;
        }
        adapters.add(adapter);
        nextFeature: for (AnnotationFeature f : schemaService.listSupportedFeatures(layer)) {
            if (!f.isEnabled()) {
                continue nextFeature;
            }
            switch(f.getLinkMode()) {
                case NONE:
                    // Nothing to do here
                    break;
                case SIMPLE:
                    adapter.addLinkFeature(f.getName(), f.getLinkTypeRoleFeatureName(), null);
                    break;
                case WITH_ROLE:
                    adapter.addLinkFeature(f.getName(), f.getLinkTypeRoleFeatureName(), f.getLinkTypeTargetFeatureName());
                    break;
                default:
                    throw new IllegalStateException("Unknown link mode [" + f.getLinkMode() + "]");
            }
            labelFeatures.add(f.getName());
        }
    }
    return adapters;
}
Also used : RelationAdapter(de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.RelationAdapter) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Collections.emptySet(java.util.Collections.emptySet) Set(java.util.Set) SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter) RelationDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.relation.RelationDiffAdapter) ArrayList(java.util.ArrayList) SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter) RelationDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.relation.RelationDiffAdapter) DiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) DiffAdapter_ImplBase(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter_ImplBase) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Aggregations

RelationAdapter (de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.RelationAdapter)1 DiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter)1 DiffAdapter_ImplBase (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter_ImplBase)1 RelationDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.relation.RelationDiffAdapter)1 SpanDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter)1 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)1 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)1 ArrayList (java.util.ArrayList)1 Collections.emptySet (java.util.Collections.emptySet)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1