<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
+ <dependency>
+ <groupId>edu.stanford.nlp</groupId>
+ <artifactId>stanford-corenlp</artifactId>
+ <version>3.8.0</version>
+ </dependency>
+ <dependency>
+ <groupId>edu.stanford.nlp</groupId>
+ <artifactId>stanford-corenlp</artifactId>
+ <version>3.8.0</version>
+ <classifier>models</classifier>
+ </dependency>
</dependencies>
</project>
--- /dev/null
+package pnews;
+
+import java.io.IOException;
+import java.util.List;
+
+import edu.stanford.nlp.ie.crf.CRFClassifier;
+import edu.stanford.nlp.ling.CoreAnnotations.AnswerAnnotation;
+import edu.stanford.nlp.ling.CoreLabel;
+
+/** https://stanfordnlp.github.io/CoreNLP/api.html */
+public class NER {
+ public static void classify(String str) throws ClassCastException, ClassNotFoundException, IOException {
+ CRFClassifier<CoreLabel> classifier;
+ List<List<CoreLabel>> out;
+ String cat, w;
+
+ classifier = CRFClassifier.getDefaultClassifier();
+ out = classifier.classify(str);
+
+ for (List<CoreLabel> labels: out)
+ for (CoreLabel l: labels) {
+ cat = l.getString(AnswerAnnotation.class);
+ w = l.word();
+ System.out.println(cat + " " + w);
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ classify("I live in Washington.");
+ }
+}
\ No newline at end of file