use of com.graphaware.nlp.processor.stanford.StanfordTextProcessor in project neo4j-nlp-stanfordnlp by graphaware.
the class DependencyParserTest method testEnhancedDependencyParsingWithComplexTest.
@Test
public void testEnhancedDependencyParsingWithComplexTest() throws Exception {
String text = "Softfoot and Small Paul would kill the Old Beard, Dirk would do Blane, and Lark and his cousins would silence Bannen and old Dywen, to keep them from sniffing after their trail.";
StanfordCoreNLP pipeline = ((StanfordTextProcessor) textProcessor).getPipeline("default");
AnnotatedText at = textProcessor.annotateText(text, "en", PIPELINE_DEFAULT);
Annotation document = new Annotation(text);
pipeline.annotate(document);
List<CoreMap> sentences = document.get(CoreAnnotations.SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
System.out.println(sentence.toString());
SemanticGraph graph = sentence.get(SemanticGraphCoreAnnotations.EnhancedDependenciesAnnotation.class);
System.out.println(graph);
for (SemanticGraphEdge edge : graph.edgeListSorted()) {
System.out.println(String.format("Source is : %s - Target is : %s - Relation is : %s", edge.getSource(), edge.getTarget(), edge.getRelation()));
}
}
}
Aggregations