List<Label> yield = tree.yield();
List<Label> preYield = tree.preTerminalYield();
assert yield.size() == preYield.size();
MorphoFeatureSpecification spec = new FrenchMorphoFeatureSpecification();
for(int i = 0; i < yield.size(); i++) {
// Morphological Analysis
String morphStr = ((CoreLabel) yield.get(i)).originalText();
if (morphStr == null || morphStr.equals("")) {
morphStr = preYield.get(i).value();
// POS subcategory
String subCat = ((CoreLabel) yield.get(i)).category();
if (subCat != null && subCat != "") {
morphStr += "-" + subCat + "--";
} else {
morphStr += "---";
}
}
MorphoFeatures feats = spec.strToFeatures(morphStr);
if(feats.getAltTag() != null && !feats.getAltTag().equals("")) {
CoreLabel cl = (CoreLabel) preYield.get(i);
cl.setValue(feats.getAltTag());
cl.setTag(feats.getAltTag());
}