Search in sources :

Example 11 with SpanAdapter

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.SpanAdapter in project webanno by webanno.

the class MergeCas method copySpanAnnotation.

/**
 * Copy this same annotation from the user annotation to the mergeview
 */
private static void copySpanAnnotation(AnnotatorState aState, AnnotationSchemaService aAnnotationService, AnnotationLayer aAnnotationLayer, AnnotationFS aOldFs, JCas aJCas) throws AnnotationException {
    SpanAdapter adapter = (SpanAdapter) aAnnotationService.getAdapter(aAnnotationLayer);
    // Create the annotation - this also takes care of attaching to an annotation if necessary
    int id = adapter.add(aState, aJCas, aOldFs.getBegin(), aOldFs.getEnd());
    List<AnnotationFeature> features = aAnnotationService.listAnnotationFeature(adapter.getLayer());
    // Copy the features
    for (AnnotationFeature feature : features) {
        Type oldType = adapter.getAnnotationType(aOldFs.getCAS());
        Feature oldFeature = oldType.getFeatureByBaseName(feature.getName());
        if (isLinkOrBasicFeatures(aOldFs, oldFeature)) {
            continue;
        }
        Object value = adapter.getFeatureValue(feature, aOldFs);
        adapter.setFeatureValue(aState, aJCas, id, feature, value);
    }
}
Also used : Type(org.apache.uima.cas.Type) SpanAdapter(de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.SpanAdapter) Feature(org.apache.uima.cas.Feature) WebAnnoCasUtil.setFeature(de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.setFeature) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Aggregations

SpanAdapter (de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.SpanAdapter)11 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)6 Type (org.apache.uima.cas.Type)6 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)6 AnnotatorState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState)5 JCas (org.apache.uima.jcas.JCas)5 TypeAdapter (de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.TypeAdapter)4 LinkWithRoleModel (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.LinkWithRoleModel)4 WebAnnoCasUtil.setFeature (de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.setFeature)4 Feature (org.apache.uima.cas.Feature)4 ArcAdapter (de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.ArcAdapter)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 CAS (org.apache.uima.cas.CAS)3 ChainAdapter (de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.ChainAdapter)2 AnnotationException (de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException)2 VID (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.VID)2 TypeUtil (de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.TypeUtil)2 WebAnnoCasUtil.selectByAddr (de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectByAddr)2 Sentence (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)2