1

I noticed that corenlp.run can identify "10am tomorrow" and parse it out as time. But the training tutorial and the docs I've seen only allow for 1 word per line. How do I get it to understand a phrase. On a related note, is there a way to tag compound entities?

1 Answers1

2

Time related phrases like that are recognized by the SUTime library. More details can be found here: https://nlp.stanford.edu/software/sutime.html

There is functionality for extracting entities after the ner tagging has been done.

For instance if you have tagged a sentence: Joe Smith went to Hawaii . as PERSON PERSON O O LOCATION O you can extract out Joe Smith and Hawaii. This requires the entitymentions annotator.

Here is some example code:

package edu.stanford.nlp.examples;

import edu.stanford.nlp.pipeline.*;
import edu.stanford.nlp.ling.*;
import edu.stanford.nlp.util.*;

import java.util.*;

public class EntityMentionsExample {

  public static void main(String[] args) {
    Annotation document =
        new Annotation("John Smith visited Los Angeles on Tuesday.");
    Properties props = new Properties();
    //props.setProperty("regexner.mapping", "small-names.rules");
    props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,entitymentions");
    StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
    pipeline.annotate(document);

    for (CoreMap entityMention : document.get(CoreAnnotations.MentionsAnnotation.class)) {
      System.out.println(entityMention);
      //System.out.println(entityMention.get(CoreAnnotations.TextAnnotation.class));
      System.out.println(entityMention.get(CoreAnnotations.EntityTypeAnnotation.class));
    }
  }
}
StanfordNLPHelp
  • 8,699
  • 1
  • 11
  • 9
  • I'm running this from the github source code and running into `Caused by: java.io.IOException: Unable to open "edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger" as class path, filename or URL` – user1170883 Apr 24 '17 at 21:45
  • 1
    You need the models jar and all of the jars in lib and liblocal in your CLASSPATH...you can download the latest models jar from the main GitHub page and the lib and liblocal folders are accessible in GitHub as well. – StanfordNLPHelp Apr 24 '17 at 23:06