List of usage examples for edu.stanford.nlp.pipeline CoNLLOutputter conllPrint
public static void conllPrint(Annotation annotation, OutputStream os) throws IOException
From source file:qa.StanfordDepParser.java
public synchronized DependencyTree parse(String documentText) throws IOException { // Create an empty Annotation just with the given text Annotation document = new Annotation(documentText); // run all Annotators on this text this.pipeline.annotate(document); // Iterate over all of the sentences found SemanticGraph ccProcessed = document.get(CoreAnnotations.SentencesAnnotation.class).get(0) .get(SemanticGraphCoreAnnotations.CollapsedCCProcessedDependenciesAnnotation.class); Collection<TypedDependency> dependencies = ccProcessed.typedDependencies(); CoNLLOutputter.conllPrint(document, new FileOutputStream(new File("temp.dep"))); String conllString = FileUtil.readCoNLLFormat("temp.dep"); //System.out.println(documentText); DependencyTree tree = DependencyTree.fromCoNLLFormatString(conllString); return tree;/*from w w w .j a v a 2 s.com*/ }
From source file:qa.StanfordDepParser.java
public String parseCoNLL(String documentText) throws IOException { // Create an empty Annotation just with the given text Annotation document = new Annotation(documentText); // run all Annotators on this text this.pipeline.annotate(document); // Iterate over all of the sentences found SemanticGraph ccProcessed = document.get(CoreAnnotations.SentencesAnnotation.class).get(0) .get(SemanticGraphCoreAnnotations.CollapsedCCProcessedDependenciesAnnotation.class); Collection<TypedDependency> dependencies = ccProcessed.typedDependencies(); CoNLLOutputter.conllPrint(document, new FileOutputStream(new File("temp.dep"))); String conllString = FileUtil.readCoNLLFormat("temp.dep"); return conllString; }