Search in sources :

Example 1 with AnnotationState

use of de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.AnnotationState in project webanno by webanno.

the class SuggestionViewPanel method addSuggestionColor.

/**
 * For each {@link ConfigurationSet}, where there are some differences in users annotation and
 * the curation annotation.
 */
private void addSuggestionColor(Project aProject, Mode aMode, Map<String, JCas> aCasMap, Map<String, Map<VID, AnnotationState>> aSuggestionColors, Collection<ConfigurationSet> aCfgSet, boolean aI, boolean aAgree) {
    for (ConfigurationSet cs : aCfgSet) {
        boolean use = false;
        for (String u : cs.getCasGroupIds()) {
            Map<VID, AnnotationState> colors = aSuggestionColors.get(u);
            if (colors == null) {
                colors = new HashMap<>();
                aSuggestionColors.put(u, colors);
            }
            for (Configuration c : cs.getConfigurations(u)) {
                FeatureStructure fs = c.getFs(u, aCasMap);
                AnnotationLayer layer = annotationService.getLayer(fs.getType().getName(), aProject);
                TypeAdapter typeAdapter = annotationService.getAdapter(layer);
                VID vid;
                // link FS
                if (c.getPosition().getFeature() != null) {
                    int fi = 0;
                    for (AnnotationFeature f : typeAdapter.listFeatures()) {
                        if (f.getName().equals(c.getPosition().getFeature())) {
                            break;
                        }
                        fi++;
                    }
                    vid = new VID(WebAnnoCasUtil.getAddr(fs), fi, c.getAID(u).index);
                } else {
                    vid = new VID(WebAnnoCasUtil.getAddr(fs));
                }
                if (aAgree) {
                    colors.put(vid, AnnotationState.AGREE);
                    continue;
                }
                // automation and correction projects
                if (!aMode.equals(Mode.CURATION) && !aAgree) {
                    if (cs.getCasGroupIds().size() == 2) {
                        colors.put(vid, AnnotationState.DO_NOT_USE);
                    } else {
                        colors.put(vid, AnnotationState.DISAGREE);
                    }
                    continue;
                }
                // this set agree with the curation annotation
                if (c.getCasGroupIds().contains(CURATION_USER)) {
                    use = true;
                } else {
                    use = false;
                }
                // this curation view
                if (u.equals(CURATION_USER)) {
                    continue;
                }
                if (aAgree) {
                    colors.put(vid, AnnotationState.AGREE);
                } else if (use) {
                    colors.put(vid, AnnotationState.USE);
                } else if (aI) {
                    colors.put(vid, AnnotationState.DISAGREE);
                } else if (!cs.getCasGroupIds().contains(CURATION_USER)) {
                    colors.put(vid, AnnotationState.DISAGREE);
                } else {
                    colors.put(vid, AnnotationState.DO_NOT_USE);
                }
            }
        }
    }
}
Also used : Configuration(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) VID(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.VID) FeatureStructure(org.apache.uima.cas.FeatureStructure) ConfigurationSet(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ConfigurationSet) TypeAdapter(de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.TypeAdapter) AnnotationState(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.AnnotationState) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Aggregations

TypeAdapter (de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.TypeAdapter)1 VID (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.VID)1 Configuration (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration)1 ConfigurationSet (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ConfigurationSet)1 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)1 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)1 AnnotationState (de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.AnnotationState)1 FeatureStructure (org.apache.uima.cas.FeatureStructure)1