public static void copyAttributes(Element element, Annotation annotation, JCas jCas) { for (NamePair names : timemlAttributeLists.get(element.getName().toUpperCase())) { String featureValue = element.getAttributeValue(names.timemlName); if (featureValue != null) { String className = annotation.getClass().getName(); String uimaName = String.format("%s:%s", className, names.uimaName); Feature feature = jCas.getTypeSystem().getFeatureByFullName(uimaName); annotation.setFeatureValueFromString(feature, featureValue); } } }
@Override protected void setValue(TOP value) { String featureValueToCopy = value.getFeatureValueAsString(this.getFeature(value)); this.annotation.setFeatureValueFromString(this.feature, featureValueToCopy); } }
public static void removeInconsistentAttributes(Element element, Annotation annotation, JCas jCas) { for (NamePair names : timemlAttributeLists.get(element.getName().toUpperCase())) { String newValue = element.getAttributeValue(names.timemlName); String className = annotation.getClass().getName(); String uimaName = String.format("%s:%s", className, names.uimaName); Feature feature = jCas.getTypeSystem().getFeatureByFullName(uimaName); String oldValue = annotation.getFeatureValueAsString(feature); if (oldValue != null && !oldValue.equals(newValue)) { annotation.setFeatureValueFromString(feature, null); } } }
@Override protected void setValue(TOP value) { String featureValueToCopy = value.getFeatureValueAsString(this.getFeature(value)); this.annotation.setFeatureValueFromString(this.feature, featureValueToCopy); } }
public static void copyAttributes(Element element, Annotation annotation, JCas jCas) { for (NamePair names : timemlAttributeLists.get(element.getName().toUpperCase())) { String featureValue = element.getAttributeValue(names.timemlName); if (featureValue != null) { String className = annotation.getClass().getName(); String uimaName = String.format("%s:%s", className, names.uimaName); Feature feature = jCas.getTypeSystem().getFeatureByFullName(uimaName); annotation.setFeatureValueFromString(feature, featureValue); } } }
@Override protected void setValue(TOP value) { String featureValueToCopy = value.getFeatureValueAsString(this.getFeature(value)); this.annotation.setFeatureValueFromString(this.feature, featureValueToCopy); } }
public static void removeInconsistentAttributes(Element element, Annotation annotation, JCas jCas) { for (NamePair names : timemlAttributeLists.get(element.getName().toUpperCase())) { String newValue = element.getAttributeValue(names.timemlName); String className = annotation.getClass().getName(); String uimaName = String.format("%s:%s", className, names.uimaName); Feature feature = jCas.getTypeSystem().getFeatureByFullName(uimaName); String oldValue = annotation.getFeatureValueAsString(feature); if (oldValue != null && !oldValue.equals(newValue)) { annotation.setFeatureValueFromString(feature, null); } } }
@Override protected void setValue(TOP value) { String featureValueToCopy = value.getFeatureValueAsString(this.getFeature(value)); this.annotation.setFeatureValueFromString(this.feature, featureValueToCopy); } }
protected void editResult(ElementParsingResult result) throws NavException { // Default behavior: Add default feature values to the created // annotation, if this is configured in the element properties for the // current annotation type String typeName = (String) nxmlDocumentParser.getTagProperties(elementName).getOrDefault(ElementProperties.TYPE, ElementProperties.TYPE_NONE); if (typeName.equals(ElementProperties.TYPE_NONE)) return; // @SuppressWarnings("unchecked") // Map<String, Object> defaultFeatureValues = (Map<String, Object>) // nxmlDocumentParser // .getTagProperties(elementName) // .getOrDefault(ElementProperties.DEFAULT_FEATURE_VALUES, // Collections.emptyMap()); @SuppressWarnings("unchecked") Map<String, Object> defaultFeatureValues = (Map<String, Object>) getApplicableProperties() .orElse(Collections.emptyMap()) .getOrDefault(ElementProperties.DEFAULT_FEATURE_VALUES, Collections.emptyMap()); for (String featureName : defaultFeatureValues.keySet()) { Feature feature = nxmlDocumentParser.cas.getTypeSystem().getType(typeName) .getFeatureByBaseName(featureName); result.getAnnotation().setFeatureValueFromString(feature, (String) defaultFeatureValues.get(featureName)); } }
@Override public void process(JCas jcas) throws AnalysisEngineProcessException { Set<Annotation> toDelete = null; if (deleteSource) { toDelete = new HashSet<Annotation>(); } for (Annotation anno : JCasUtil.select(jcas, sourceClass)) { Annotation newAnnotation = AnnotationFactory.createAnnotation(jcas, anno.getBegin(), anno.getEnd(), targetClass); if (deleteSource) toDelete.add(anno); if (!(targetFeatureName.isEmpty() || targetFeatureValue.isEmpty())) { Feature feature = newAnnotation.getType().getFeatureByBaseName(targetFeatureName); if (feature != null) newAnnotation.setFeatureValueFromString(feature, targetFeatureValue); } } if (deleteSource) { for (Annotation a : toDelete) { a.removeFromIndexes(); } } }
mergedAnno.setFeatureValueFromString(feature, currentValue);
chunk.setFeatureValueFromString(feature, outcome.label);
Annotation newAnno = AnnotationFactory.createAnnotation(jcas, begin, end, targetAnnotation); if (feature != null) newAnno.setFeatureValueFromString(feature, wordList.listName);
token.setFeatureValueFromString(featPOS, posTag);
targetAnnotation); if (feature != null) newAnno.setFeatureValueFromString(feature, wordList.listName); targetAnnotation); if (feature != null) newAnno.setFeatureValueFromString(feature, wordList.listName);