Search in sources :

Example 1 with NomLexEntry

use of edu.illinois.cs.cogcomp.edison.utilities.NomLexEntry 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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) NomLexEntry(edu.illinois.cs.cogcomp.edison.utilities.NomLexEntry) NomLexReader(edu.illinois.cs.cogcomp.edison.utilities.NomLexReader) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) Feature(edu.illinois.cs.cogcomp.edison.features.Feature) DiscreteFeature(edu.illinois.cs.cogcomp.edison.features.DiscreteFeature)

Aggregations

TextAnnotation (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation)1 DiscreteFeature (edu.illinois.cs.cogcomp.edison.features.DiscreteFeature)1 Feature (edu.illinois.cs.cogcomp.edison.features.Feature)1 NomLexEntry (edu.illinois.cs.cogcomp.edison.utilities.NomLexEntry)1 NomLexReader (edu.illinois.cs.cogcomp.edison.utilities.NomLexReader)1 LinkedHashSet (java.util.LinkedHashSet)1