private Collection<TypedDependency> parseSentenceTDL(String text) { System.out.println("Parsing sentence..."); Collection<TypedDependency> tdl = null; TreebankLanguagePack tlp = lp.treebankLanguagePack(); GrammaticalStructureFactory gsf = null; if (tlp.supportsGrammaticalStructures()) { gsf = tlp.grammaticalStructureFactory(); } Reader reader = new StringReader(text); for (List<HasWord> sentence : new DocumentPreprocessor(reader)) { Tree parse = lp.apply(sentence); if (gsf != null) { GrammaticalStructure gs = gsf.newGrammaticalStructure(parse); tdl = gs.allTypedDependencies(); } } return tdl; }