StanfordOpenIEAnnotator

Extracting RDF triples from Natural text with Java, NLP4J

Code

// <!-- https://mvnrepository.com/artifact/org.nlp4j/nlp4j-core -->
// <!-- https://mvnrepository.com/artifact/org.nlp4j/nlp4j-stanford -->
// import nlp4j.Document;
// import nlp4j.impl.DefaultDocument;
// import nlp4j.stanford.StanfordOpenIEAnnotator;

Document doc = new DefaultDocument();
doc.putAttribute("text", //
		"Mount Fuji, located on the island of Honshu, " //
				+ "is the highest mountain in Japan. ");
StanfordOpenIEAnnotator ann = new StanfordOpenIEAnnotator();

ann.setProperty("target", "text");
ann.annotate(doc);

doc.getKeywords().forEach(kwd -> System.err.println(kwd.getLex()));

Result

mount fuji , is highest mountain in , japan
mount fuji , is mountain in , japan
mount fuji , is , mountain
mount fuji , is , highest mountain
mount fuji , located on , island honshu
highest mountain , is in , japan
mount fuji , located on , island
Mount Fuji located on the island of Honshu is the highest mountain in Japan
Mount Fuji located on the island of Honshu