Search in sources :

Example 21 with TokenLabelView

use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.TokenLabelView in project cogcomp-nlp by CogComp.

the class SentenceStructure method getView.

public TokenLabelView getView(SenseManager manager, TextAnnotation ta) {
    String viewName = SenseManager.getPredictedViewName();
    TokenLabelView view = new TokenLabelView(viewName, VerbSenseConstants.systemIdentifier, ta, 1.0);
    for (SenseStructure y : this.ys) {
        SenseInstance senseInstance = y.getInstance();
        IntPair predicateSpan = senseInstance.getConstituent().getSpan();
        String sense = manager.getSense(y.getLabel());
        view.addTokenLabel(predicateSpan.getFirst(), sense, 1.0);
    }
    return view;
}
Also used : TokenLabelView(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TokenLabelView) IntPair(edu.illinois.cs.cogcomp.core.datastructures.IntPair)

Example 22 with TokenLabelView

use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.TokenLabelView in project cogcomp-nlp by CogComp.

the class SenseExampleGenerator method getTreebankExamples.

private void getTreebankExamples(TextAnnotation ta, List<SenseInstance> predicates, List<SenseStructure> structures) {
    TokenLabelView view = (TokenLabelView) ta.getView(SenseManager.getGoldViewName());
    for (Constituent predicate : view.getConstituents()) {
        if (!predicate.hasAttribute(PredicateArgumentView.LemmaIdentifier)) {
            System.out.println(ta);
            System.out.println(view);
            System.out.println(predicate + " has no lemma!");
            assert false;
        }
        SenseInstance x = new SenseInstance(predicate, manager);
        int sense = manager.getSenseId(predicate.getLabel());
        SenseStructure y = new SenseStructure(x, sense, manager);
        predicates.add(x);
        structures.add(y);
    }
}
Also used : SenseStructure(edu.illinois.cs.cogcomp.verbsense.jlis.SenseStructure) SenseInstance(edu.illinois.cs.cogcomp.verbsense.jlis.SenseInstance) TokenLabelView(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TokenLabelView) Constituent(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent)

Aggregations

TokenLabelView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TokenLabelView)22 TextAnnotation (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation)13 Constituent (edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent)5 DiscreteFeature (edu.illinois.cs.cogcomp.edison.features.DiscreteFeature)5 Feature (edu.illinois.cs.cogcomp.edison.features.Feature)5 LinkedHashSet (java.util.LinkedHashSet)5 IntPair (edu.illinois.cs.cogcomp.core.datastructures.IntPair)2 SpanLabelView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.SpanLabelView)2 ILPSolverFactory (edu.illinois.cs.cogcomp.infer.ilp.ILPSolverFactory)2 ILPInference (edu.illinois.cs.cogcomp.verbsense.inference.ILPInference)2 ArrayList (java.util.ArrayList)2 JWNLException (net.didion.jwnl.JWNLException)2 POS (net.didion.jwnl.data.POS)2 AnnotatorException (edu.illinois.cs.cogcomp.annotation.AnnotatorException)1 Comma (edu.illinois.cs.cogcomp.comma.datastructures.Comma)1 CommaSRLSentence (edu.illinois.cs.cogcomp.comma.datastructures.CommaSRLSentence)1 Pair (edu.illinois.cs.cogcomp.core.datastructures.Pair)1 TreeView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TreeView)1 Tree (edu.illinois.cs.cogcomp.core.datastructures.trees.Tree)1 ClassificationTester (edu.illinois.cs.cogcomp.core.experiments.ClassificationTester)1