/** * Set a feature value. * * @param aFS * the feature structure. * @param aFeatureName * the feature within the annotation whose value to set. * @param aValue * the feature value. */ public static void setFeature(FeatureStructure aFS, String aFeatureName, String aValue) { Feature labelFeature = aFS.getType().getFeatureByBaseName(aFeatureName); aFS.setFeatureValueFromString(labelFeature, aValue); }
/** * Set a feature value. * * @param aFS * the feature structure. * @param aFeature * the feature within the annotation whose value to set. If this parameter is * {@code null} then nothing happens. * @param aValue * the feature value. */ public static void setFeature(FeatureStructure aFS, AnnotationFeature aFeature, String aValue) { if (aFeature != null) { Feature labelFeature = aFS.getType().getFeatureByBaseName(aFeature.getName()); aFS.setFeatureValueFromString(labelFeature, aValue); } }
@Override public void updateFeature(JCas aJcas, AnnotationFeature aFeature,int aAddress, String aValue) { Type type = CasUtil.getType(aJcas.getCas(), aFeature.getLayer().getName()+LINK); Feature feature = type.getFeatureByBaseName(aFeature.getName()); FeatureStructure fs = BratAjaxCasUtil.selectByAddr(aJcas, FeatureStructure.class, aAddress); fs.setFeatureValueFromString(feature, aValue); }
private void copyFeatures(AnnotationFS oldFS, FeatureStructure newFS, CAS cas) { List<?> features = oldFS.getType().getFeatures(); Type newType = newFS.getType(); for (Object object : features) { Feature feature = (Feature) object; String shortName = feature.getShortName(); Feature newFeature = newType.getFeatureByBaseName(shortName); if (newFeature != null) { if (feature.getRange().isPrimitive()) { String value = oldFS.getFeatureValueAsString(feature); newFS.setFeatureValueFromString(newFeature, value); } else { FeatureStructure value = oldFS.getFeatureValue(feature); newFS.setFeatureValue(newFeature, value); } } } }
private void copyFeatures(AnnotationFS oldFS, FeatureStructure newFS, CAS cas) { List<?> features = oldFS.getType().getFeatures(); Type newType = newFS.getType(); for (Object object : features) { Feature feature = (Feature) object; String shortName = feature.getShortName(); Feature newFeature = newType.getFeatureByBaseName(shortName); if (newFeature != null) { if (feature.getRange().isPrimitive()) { String value = oldFS.getFeatureValueAsString(newFeature); newFS.setFeatureValueFromString(newFeature, value); } else { FeatureStructure value = oldFS.getFeatureValue(feature); newFS.setFeatureValue(newFeature, value); } } } }
featureValue.getFeatureStructure().setFeatureValueFromString(featureValue.getFeature(), (String) value);
aDestFS.setFeatureValueFromString(destFeat, aSrcFS.getFeatureValueAsString(srcFeat));