use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature 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;
}
use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature in project webanno by webanno.
the class SlotFeatureSupport method getFeatureValue.
@Override
public <T> T getFeatureValue(AnnotationFeature aFeature, FeatureStructure aFS) {
// Get type and features - we need them later in the loop
Feature linkFeature = aFS.getType().getFeatureByBaseName(aFeature.getName());
Type linkType = aFS.getCAS().getTypeSystem().getType(aFeature.getLinkTypeName());
Feature roleFeat = linkType.getFeatureByBaseName(aFeature.getLinkTypeRoleFeatureName());
Feature targetFeat = linkType.getFeatureByBaseName(aFeature.getLinkTypeTargetFeatureName());
List<LinkWithRoleModel> links = new ArrayList<>();
ArrayFS array = (ArrayFS) aFS.getFeatureValue(linkFeature);
if (array != null) {
for (FeatureStructure link : array.toArray()) {
LinkWithRoleModel m = new LinkWithRoleModel();
m.role = link.getStringValue(roleFeat);
m.targetAddr = WebAnnoCasUtil.getAddr(link.getFeatureValue(targetFeat));
m.label = ((AnnotationFS) link.getFeatureValue(targetFeat)).getCoveredText();
links.add(m);
}
}
return (T) links;
}
use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature in project webanno by webanno.
the class TypeAdapter_ImplBase method getValue.
private Object getValue(FeatureStructure fs, AnnotationFeature aFeature) {
Object value;
Feature f = fs.getType().getFeatureByBaseName(aFeature.getName());
if (f.getRange().isPrimitive()) {
value = FSUtil.getFeature(fs, aFeature.getName(), Object.class);
} else if (FSUtil.isMultiValuedFeature(fs, f)) {
value = FSUtil.getFeature(fs, aFeature.getName(), List.class);
} else {
value = FSUtil.getFeature(fs, aFeature.getName(), FeatureStructure.class);
}
return value;
}
use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature in project webanno by webanno.
the class WebAnnoCasUtil method setLinkFeature.
private static void setLinkFeature(FeatureStructure aFS, AnnotationFeature aFeature, List<LinkWithRoleModel> aValue, Feature feature) {
Type linkType = aFS.getCAS().getTypeSystem().getType(aFeature.getLinkTypeName());
Feature roleFeat = linkType.getFeatureByBaseName(aFeature.getLinkTypeRoleFeatureName());
Feature targetFeat = linkType.getFeatureByBaseName(aFeature.getLinkTypeTargetFeatureName());
// Create all the links
// FIXME: actually we could re-use existing link link feature structures
List<FeatureStructure> linkFSes = new ArrayList<>();
if (aValue != null) {
// remove duplicate links
Set<LinkWithRoleModel> links = new HashSet<>(aValue);
for (LinkWithRoleModel e : links) {
// set
if (e.targetAddr == -1) {
continue;
}
FeatureStructure link = aFS.getCAS().createFS(linkType);
link.setStringValue(roleFeat, e.role);
link.setFeatureValue(targetFeat, selectByAddr(aFS.getCAS(), e.targetAddr));
linkFSes.add(link);
}
}
setLinkFeatureValue(aFS, feature, linkFSes);
}
use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature in project webanno by webanno.
the class TypeSystemAnalysis method analyzeFeatures.
private void analyzeFeatures(AnnotationLayer aLayer, TypeSystem aTS, TypeDescription aTD, Optional<? extends LayerDetails> aDetails) {
Type type = aTS.getType(aTD.getName());
for (FeatureDescription fd : aTD.getFeatures()) {
Feature feat = type.getFeatureByBaseName(fd.getName());
// We do not need to set up built-in features
if (isBuiltInFeature(feat)) {
continue;
}
if (aDetails.isPresent() && aDetails.get().isHiddenFeature(feat)) {
continue;
}
AnnotationFeature f = analyzeFeature(aTS, fd, feat);
features.put(aLayer.getName(), f);
}
}
Aggregations