use of edu.illinois.cs.cogcomp.edison.utilities.NomLexReader in project cogcomp-nlp by CogComp.
the class NomLexClassFeature method getFeatures.
@Override
public Set<Feature> getFeatures(Constituent c) throws EdisonException {
int tokenId = c.getEndSpan() - 1;
TextAnnotation ta = c.getTextAnnotation();
String predicateWord = ta.getToken(tokenId).toLowerCase().trim();
String predicateLemma;
if (c.hasAttribute(PredicateArgumentView.LemmaIdentifier))
predicateLemma = c.getAttribute(PredicateArgumentView.LemmaIdentifier);
else
predicateLemma = WordHelpers.getLemma(ta, tokenId);
NomLexReader nomLex = NomLexReader.getInstance();
List<NomLexEntry> nomLexEntries = nomLex.getNomLexEntries(predicateWord, predicateLemma);
Set<Feature> features = new LinkedHashSet<>();
if (nomLexEntries.size() > 0) {
for (NomLexEntry e : nomLexEntries) {
features.add(DiscreteFeature.create("nom-cls:" + e.nomClass));
if (NomLexEntry.VERBAL.contains(e.nomClass)) {
features.add(DE_VERBAL);
features.add(DiscreteFeature.create("nom-vb:" + e.verb));
} else if (NomLexEntry.ADJECTIVAL.contains(e.nomClass)) {
features.add(DE_ADJECTIVAL);
features.add(DiscreteFeature.create("nom-adj:" + e.adj));
}
}
}
return features;
}
Aggregations