public static String getFeatureValueByType(CasData aCAS, String featureName) {
Iterator<FeatureStructure> it = aCAS.getFeatureStructures();
String featureValue = null;
while (it.hasNext()) {
FeatureStructure fs = it.next();
if (System.getProperty("DEBUG") != null)
System.out.println("FeatureName::::::::::::::::::::::::::::::::::::::::::>"
+ fs.getType() + " Searching For::" + featureName);
if (featureName.equals(fs.getType())) {
String[] names = fs.getFeatureNames();
for (int i = 0; names != null && i < names.length; i++) {
if (System.getProperty("DEBUG") != null)
System.out.println("Feature Structure:::" + fs.getType() + " Has Value::" + names[i]);
}
if ("uima.cpm.DocumentText".equals(featureName) || "UTF8:UTF8Content".equals(featureName)) {
FeatureValue fValue = fs.getFeatureValue("value");
if (fValue == null) {
return null;
}
return fValue.toString();
} else if ("Detag:DetagContent".equals(featureName)) {
FeatureValue fValue = fs.getFeatureValue("Doc:SpannedText");
if (fValue == null) {
return null;
}
return fValue.toString();
}
FeatureValue fValue = fs.getFeatureValue(featureName);
if (fValue != null) {
featureValue = fValue.toString();
break;
}
}