Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Properties props = new Properties();
- props.put("parse.flags", "");
- props.put("pos.model", "lib/stanford-postagger-full-2013-06-20/models/english-left3words-distsim.tagger");
- props.put("annotators", "tokenize, ssplit, pos, lemma, parse");
- props.put("parse.model", "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz");
- StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
- Annotation document = new Annotation("The dog was taken for a walk.");
- pipeline.annotate(document);
- List<CoreMap> sentences = document.get(SentencesAnnotation.class);
- for (CoreMap sentence: sentences)
- {
- Tree tree = sentence.get(TreeAnnotation.class);
- TreebankLanguagePack languagePack = new PennTreebankLanguagePack();
- Collection<TypedDependency> typedDependencies = languagePack.grammaticalStructureFactory().newGrammaticalStructure(tree).typedDependenciesCollapsed();
- for(TypedDependency tdep : typedDependencies)
- {
- System.out.println("reln: " + tdep.reln());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement