Search in sources :

Example 1 with FeatureSupportRegistry

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

the class Renderer method getFeatures.

default Map<String, String> getFeatures(TypeAdapter aAdapter, AnnotationFS aFs, List<AnnotationFeature> aFeatures) {
    FeatureSupportRegistry fsr = getFeatureSupportRegistry();
    Map<String, String> features = new LinkedHashMap<>();
    for (AnnotationFeature feature : aFeatures) {
        if (!feature.isEnabled() || !feature.isVisible() || !MultiValueMode.NONE.equals(feature.getMultiValueMode())) {
            continue;
        }
        Feature labelFeature = aFs.getType().getFeatureByBaseName(feature.getName());
        String label = defaultString(fsr.getFeatureSupport(feature).renderFeatureValue(feature, aFs, labelFeature));
        features.put(feature.getName(), label);
    }
    return features;
}
Also used : FeatureSupportRegistry(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.FeatureSupportRegistry) StringUtils.defaultString(org.apache.commons.lang3.StringUtils.defaultString) Feature(org.apache.uima.cas.Feature) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) LinkedHashMap(java.util.LinkedHashMap) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Example 2 with FeatureSupportRegistry

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

the class Renderer method getHoverFeatures.

default Map<String, String> getHoverFeatures(TypeAdapter aAdapter, AnnotationFS aFs, List<AnnotationFeature> aFeatures) {
    FeatureSupportRegistry fsr = getFeatureSupportRegistry();
    Map<String, String> hoverfeatures = new LinkedHashMap<>();
    if (aAdapter.getLayer().isShowTextInHover())
        hoverfeatures.put("__spantext__", aFs.getCoveredText());
    for (AnnotationFeature feature : aFeatures) {
        if (!feature.isEnabled() || !feature.isIncludeInHover() || !MultiValueMode.NONE.equals(feature.getMultiValueMode())) {
            continue;
        }
        Feature labelFeature = aFs.getType().getFeatureByBaseName(feature.getName());
        String text = defaultString(fsr.getFeatureSupport(feature).renderFeatureValue(feature, aFs, labelFeature));
        hoverfeatures.put(feature.getName(), text);
    }
    return hoverfeatures;
}
Also used : FeatureSupportRegistry(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.FeatureSupportRegistry) StringUtils.defaultString(org.apache.commons.lang3.StringUtils.defaultString) Feature(org.apache.uima.cas.Feature) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) LinkedHashMap(java.util.LinkedHashMap) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Aggregations

FeatureSupportRegistry (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.FeatureSupportRegistry)2 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)2 LinkedHashMap (java.util.LinkedHashMap)2 StringUtils.defaultString (org.apache.commons.lang3.StringUtils.defaultString)2 Feature (org.apache.uima.cas.Feature)2