use of edu.illinois.cs.cogcomp.edison.utilities.EdisonException in project cogcomp-nlp by CogComp.
the class ParseHeadWordPOS method getFeatures.
@Override
public Set<Feature> getFeatures(Constituent c) throws EdisonException {
TextAnnotation ta = c.getTextAnnotation();
TreeView tree = (TreeView) ta.getView(parseViewName);
Constituent phrase;
try {
phrase = tree.getParsePhrase(c);
} catch (Exception e) {
throw new EdisonException(e);
}
Set<Feature> features = new LinkedHashSet<>();
int head = CollinsHeadFinder.getInstance().getHeadWordPosition(phrase);
features.add(DiscreteFeature.create("hw:" + ta.getToken(head).toLowerCase().trim()));
features.add(DiscreteFeature.create("h-pos:" + WordHelpers.getPOS(ta, head)));
return features;
}
Aggregations