Betafish
Betafish

Reputation: 1262

How to choose Coreference resolution system in Stanford CoreNLP

I am trying to test the coreference resolution system from core-nlp. From Running coreference resolution on raw text, I understand setting the general properties for the 'dcoref system'.

I would like to choose between the co-reference systems [Deterministic, Statistical, Neural] based on the latency of the module. The command line usage is clear for me, how do I use this option as an API?.

currently, I'm running the default code:

public static void main(String[] args) throws Exception {
    Annotation document = new Annotation("Barack Obama was born in Hawaii.  He is the president. Obama was elected in 2008.");
    Properties props = new Properties();
    props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,mention,coref");
    StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
    pipeline.annotate(document);
    System.out.println("---");
    System.out.println("coref chains");
    for (CorefChain cc : document.get(CorefCoreAnnotations.CorefChainAnnotation.class).values()) {
      System.out.println("\t" + cc);
    }
    for (CoreMap sentence : document.get(CoreAnnotations.SentencesAnnotation.class)) {
      System.out.println("---");
      System.out.println("mentions");
      for (Mention m : sentence.get(CorefCoreAnnotations.CorefMentionsAnnotation.class)) {
        System.out.println("\t" + m);
       }
    }

Upvotes: 0

Views: 1041

Answers (1)

Betafish
Betafish

Reputation: 1262

W'll, after digging up the corefProperties.class I found out the properties that needs to be changed.

 props.setProperty("coref.language", "en");
 props.setProperty("coref.algorithm", "statistical");//"statistical" : "neural"

But, whats more surprising is that, to execute the above sample test text. Statistical method takes around :45 secs and Neural takes around 30 secs. (Intel i5 @2.00Ghz, 8GB Memory). Am I missing something here?

Upvotes: 2

Related Questions