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();
}
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);
}
}
}
}
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());
}
}
}
}
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));
}
}
}
}
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));
}
}
Aggregations