edu.stanford.nlp.trees.PennTreebankLanguagePack Java Examples

The following examples show how to use edu.stanford.nlp.trees.PennTreebankLanguagePack. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NERTool.java    From Criteria2Query with Apache License 2.0 6 votes vote down vote up
/**
 * Word Dependency Author:chi Date:2017-3-22
 * 
 */
public Collection<TypedDependency> outputDependency(Tree t) {
	TreebankLanguagePack tlp = new PennTreebankLanguagePack();
	// tlp.setGenerateOriginalDependencies(true); Standford Dependency
	GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
	GrammaticalStructure gs = gsf.newGrammaticalStructure(t);

	Collection<TypedDependency> tdl = gs.typedDependenciesCCprocessed();

	int countforitem = 0;
	int source = 0;
	int target = 0;
	for (TypedDependency item : tdl) {
		System.out.println(item);
	}
	
	return tdl;

}
 
Example #2
Source File: MainTest.java    From dependensee with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test of writeImage method, of class Main.
 */

@Test
public void testWriteImage() throws Exception {
    String text = "A quick brown fox jumped over the lazy dog.";
    TreebankLanguagePack tlp = new PennTreebankLanguagePack();
    GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
    LexicalizedParser lp = LexicalizedParser.loadModel();
    lp.setOptionFlags(new String[]{"-maxLength", "500", "-retainTmpSubcategories"});
    TokenizerFactory<CoreLabel> tokenizerFactory =
            PTBTokenizer.factory(new CoreLabelTokenFactory(), "");
    List<CoreLabel> wordList = tokenizerFactory.getTokenizer(new StringReader(text)).tokenize();
    Tree tree = lp.apply(wordList);
    GrammaticalStructure gs = gsf.newGrammaticalStructure(tree);
    Collection<TypedDependency> tdl = gs.typedDependenciesCollapsed();
    Main.writeImage(tdl, "image.png", 3);
    assert (new File("image.png").exists());
}
 
Example #3
Source File: CoreNLP.java    From Criteria2Query with Apache License 2.0 5 votes vote down vote up
/**
 * Word Dependency Author:chi Date:2017-3-22
 * 
 */
public Collection<TypedDependency> outputDependency(Tree t) {
	TreebankLanguagePack tlp = new PennTreebankLanguagePack();
	// tlp.setGenerateOriginalDependencies(true); Standford Dependency
	GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
	GrammaticalStructure gs = gsf.newGrammaticalStructure(t);
	
	Collection<TypedDependency> tdl = gs.typedDependenciesCCprocessed();
	
	int countforitem = 0;
	int source = 0;
	int target = 0;
	return tdl;

}
 
Example #4
Source File: StanfordParser.java    From gAnswer with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public StanfordParser() {
	lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz");
    tokenizerFactory = PTBTokenizer.factory(new CoreLabelTokenFactory(), "");
    tlp = new PennTreebankLanguagePack();
    gsf = tlp.grammaticalStructureFactory();
}