use of edu.stanford.nlp.pipeline.StanfordCoreNLP in project Info-Evaluation by TechnionYP5777.
the class AnalyzeParagragh method InteractiveAnalyze.
public InteractiveTableTuple InteractiveAnalyze() {
final String $ = getName();
final String input_date = getDate(year);
String accurate_name = "";
LinkedList<ReasonPair> reasons = InteractiveReasonFinding();
final Properties props = new Properties();
props.put("annotators", "tokenize,ssplit, pos, regexner, parse,lemma,natlog,openie");
final StanfordCoreNLP pipeLine = new StanfordCoreNLP(props);
final String inputText = input + "";
final Annotation document = new Annotation(inputText);
pipeLine.annotate(document);
for (final CoreMap sentence : document.get(SentencesAnnotation.class)) {
final SemanticGraph dependencies = sentence.get(CollapsedDependenciesAnnotation.class);
for (final IndexedWord root : dependencies.getRoots()) for (final SemanticGraphEdge edge : dependencies.getOutEdgesSorted(root)) {
final IndexedWord dep = edge.getDependent();
if ("nsubjpass".equals((edge.getRelation() + ""))) {
for (final SemanticGraphEdge keshet : dependencies.getOutEdgesSorted(dep)) {
final IndexedWord dep2 = keshet.getDependent();
final String rel2 = keshet.getRelation() + "";
if ("arrested".equals(edge.getGovernor().word()) && ((dep2.ner() != null && "PERSON".equals(dep2.ner())) || "compound".equals(rel2) || "det".equals(rel2)))
accurate_name += dep2.word() + " ";
}
accurate_name += dep.word();
}
}
}
return new InteractiveTableTuple(accurate_name.isEmpty() ? $ : accurate_name, input_date, reasons);
}
use of edu.stanford.nlp.pipeline.StanfordCoreNLP in project Info-Evaluation by TechnionYP5777.
the class AnalyzePage method createParagraphs.
private List<String> createParagraphs() {
final Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit");
props.setProperty("ssplit.eolonly", "true");
final StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
final Annotation document1 = new Annotation(originalText);
pipeline.annotate(document1);
final List<CoreMap> sentences = document1.get(CoreAnnotations.SentencesAnnotation.class);
final List<String> $ = new ArrayList<>();
for (final CoreMap ¢ : sentences) $.add(¢ + "");
return $;
}
Aggregations