Search in sources :

Example 1 with PredicateArgumentView

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

the class ParsePhraseTypeOnlyTest method setUp.

@Before
public void setUp() throws Exception {
    String[] viewsToAdd = { ViewNames.PARSE_STANFORD, ViewNames.PARSE_CHARNIAK, ViewNames.PARSE_GOLD, ViewNames.SRL_VERB };
    TextAnnotation ta = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(viewsToAdd, false, 3);
    PredicateArgumentView srlView = (PredicateArgumentView) ta.getView(ViewNames.SRL_VERB);
    predicate = srlView.getPredicates().get(0);
    List<Relation> arguments = new ArrayList<>(srlView.getArguments(predicate));
    // Making the order of arg1 and arg2 deterministic by sorting them according to their relation target.
    arguments.sort((o1, o2) -> Integer.compare(o1.getTarget().getStartSpan(), o2.getTarget().getStartSpan()));
    arg1 = arguments.get(0).getTarget();
    arg2 = arguments.get(1).getTarget();
}
Also used : Relation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Relation) ArrayList(java.util.ArrayList) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) PredicateArgumentView(edu.illinois.cs.cogcomp.core.datastructures.textannotation.PredicateArgumentView) Before(org.junit.Before)

Example 2 with PredicateArgumentView

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

the class TestClauseFeatureExtractor method testFex.

private void testFex(FeatureExtractor fex) throws Exception {
    for (TextAnnotation ta : tas) {
        if (!ta.hasView(ViewNames.PARSE_CHARNIAK))
            continue;
        ta.addView(ClauseViewGenerator.CHARNIAK);
        ta.addView(PseudoParse.CHARNIAK);
        PredicateArgumentView pav = (PredicateArgumentView) ta.getView(ViewNames.SRL_VERB);
        for (Constituent predicate : pav.getPredicates()) {
            Constituent p = predicate.cloneForNewView("dummy");
            for (Relation arg : pav.getArguments(predicate)) {
                Constituent c = arg.getTarget().cloneForNewView("dummy");
                new Relation("", p, c, 1.0);
                Set<Feature> features = fex.getFeatures(c);
                logger.info(c + "\t" + features);
            }
        }
    }
}
Also used : Relation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Relation) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) Feature(edu.illinois.cs.cogcomp.edison.features.Feature) PredicateArgumentView(edu.illinois.cs.cogcomp.core.datastructures.textannotation.PredicateArgumentView) Constituent(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent)

Example 3 with PredicateArgumentView

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

the class TestSyntacticFrame method testFex.

private void testFex(FeatureExtractor fex) throws Exception {
    for (TextAnnotation ta : tas) {
        if (!ta.hasView(ViewNames.PARSE_CHARNIAK))
            continue;
        PredicateArgumentView pav = (PredicateArgumentView) ta.getView(ViewNames.SRL_VERB);
        for (Constituent predicate : pav.getPredicates()) {
            Constituent p = predicate.cloneForNewView("dummy");
            for (Relation arg : pav.getArguments(predicate)) {
                Constituent c = arg.getTarget().cloneForNewView("dummy");
                new Relation("", p, c, 1.0);
                Set<Feature> features = fex.getFeatures(c);
                logger.info(c + "\t" + features);
                assertEquals(3, features.size());
            }
        }
    }
}
Also used : Relation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Relation) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) Feature(edu.illinois.cs.cogcomp.edison.features.Feature) PredicateArgumentView(edu.illinois.cs.cogcomp.core.datastructures.textannotation.PredicateArgumentView) Constituent(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent)

Example 4 with PredicateArgumentView

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

the class TestChunkFeatures method testFex.

private void testFex(FeatureExtractor fex, boolean printBoth, String... viewNames) throws EdisonException {
    for (TextAnnotation ta : tas) {
        for (String viewName : viewNames) if (ta.hasView(viewName))
            logger.info(ta.getView(viewName).toString());
        if (!ta.hasView(ViewNames.SRL_VERB))
            continue;
        PredicateArgumentView pav = (PredicateArgumentView) ta.getView(ViewNames.SRL_VERB);
        for (Constituent predicate : pav.getPredicates()) {
            Constituent p = predicate.cloneForNewView("dummy");
            for (Relation argument : pav.getArguments(predicate)) {
                Constituent c = argument.getTarget().cloneForNewView("dummy");
                Relation r = new Relation("", p, c, 1);
                logger.info((printBoth ? r : c) + "\t" + fex.getFeatures(c));
            }
        }
    }
}
Also used : Relation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Relation) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) PredicateArgumentView(edu.illinois.cs.cogcomp.core.datastructures.textannotation.PredicateArgumentView) Constituent(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent)

Example 5 with PredicateArgumentView

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

the class TestVerbClassFeatures method test.

@Test
public final void test() throws Exception {
    TextAnnotation ta = tas.get(tas.size() - 1);
    PredicateArgumentView pav = (PredicateArgumentView) ta.getView(ViewNames.SRL_VERB);
    for (Constituent predicate : pav.getPredicates()) {
        Constituent p = predicate.cloneForNewView("dummy");
        String response = p + "\t" + LevinVerbClassFeature.instance.getFeatures(p);
        assertTrue(correctResponses.contains(response));
    }
}
Also used : TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) PredicateArgumentView(edu.illinois.cs.cogcomp.core.datastructures.textannotation.PredicateArgumentView) Constituent(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent) Test(org.junit.Test)

Aggregations

PredicateArgumentView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.PredicateArgumentView)8 Constituent (edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent)7 Relation (edu.illinois.cs.cogcomp.core.datastructures.textannotation.Relation)5 TextAnnotation (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation)5 IntPair (edu.illinois.cs.cogcomp.core.datastructures.IntPair)2 Feature (edu.illinois.cs.cogcomp.edison.features.Feature)2 ArrayList (java.util.ArrayList)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 Tree (edu.illinois.cs.cogcomp.core.datastructures.trees.Tree)1 LinkedList (java.util.LinkedList)1 TreeSet (java.util.TreeSet)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Predicate (se.lth.cs.srl.corpus.Predicate)1 Sentence (se.lth.cs.srl.corpus.Sentence)1 Word (se.lth.cs.srl.corpus.Word)1 Yield (se.lth.cs.srl.corpus.Yield)1