Advertisement
Guest User

Java Passive Detection

a guest
Oct 22nd, 2013
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. Properties props = new Properties();
  2. props.put("parse.flags", "");
  3. props.put("pos.model", "lib/stanford-postagger-full-2013-06-20/models/english-left3words-distsim.tagger");
  4. props.put("annotators", "tokenize, ssplit, pos, lemma, parse");
  5. props.put("parse.model", "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz");
  6.  
  7. StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
  8. Annotation document = new Annotation("The dog was taken for a walk.");
  9. pipeline.annotate(document);
  10.  
  11. List<CoreMap> sentences = document.get(SentencesAnnotation.class);
  12.  
  13. for (CoreMap sentence: sentences)
  14. {
  15.     Tree tree = sentence.get(TreeAnnotation.class);
  16.     TreebankLanguagePack languagePack = new PennTreebankLanguagePack();
  17.     Collection<TypedDependency> typedDependencies = languagePack.grammaticalStructureFactory().newGrammaticalStructure(tree).typedDependenciesCollapsed();
  18.  
  19.     for(TypedDependency tdep : typedDependencies)
  20.     {
  21.         System.out.println("reln: " + tdep.reln());
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement