Stanford NLP:java.lang.IllegalArgumentException:没有名为openie的注释器

时间:2016-01-25 14:45:52

标签: java stanford-nlp

我想知道是否有人可以帮助我。

我正在使用stanford-corenlp 3.5.2 maven包从教程中运行OpenIEDemo。

我收到以下输出: -

  

添加注释器标记化TokenizerAnnotator:没有标记器类型   提供。默认为PTBTokenizer。添加注释器ssplit添加   annotator pos阅读POS标签模型   埃杜/斯坦福/ NLP /模型/ POS-恶搞/英left3words /英left3words-distsim.tagger   ......完成[1.5秒]。添加注释引理添加注释器depparse   加载depparse模型文件:   edu / stanford / nlp / models / parser / nndep / english_UD.gz ... PreComputed   100000,已用时间:1.451(s)初始化依赖性解析器已完成   [4.7秒]。添加注释器解析从序列化文件中加载解析器   edu / stanford / nlp / models / lexparser / englishPCFG.ser.gz ... done [2.2   秒]。添加注释器natlog添加注释器openie异常   thread“main”java.lang.IllegalArgumentException:没有命名的注释器   openie           在edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:83)           在edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:289)           在edu.stanford.nlp.pipeline.StanfordCoreNLP。(StanfordCoreNLP.java:126)           在edu.stanford.nlp.pipeline.StanfordCoreNLP。(StanfordCoreNLP.java:122)           在com.test.OpenIEDemo.OpenIEDemo.main(OpenIEDemo.java:22)

代码与教程相同,但

除外
  1. 我更改了包名称。
  2. 我之前有一个错误,即解析注释器是natlog注释器的依赖项,因此将解析注释器添加到注释器属性中。
  3. package com.test.OpenIEDemo;
    
    import edu.stanford.nlp.ie.util.RelationTriple;
    import edu.stanford.nlp.ling.CoreAnnotations;
    import edu.stanford.nlp.pipeline.Annotation;
    import edu.stanford.nlp.pipeline.StanfordCoreNLP;
    import edu.stanford.nlp.naturalli.*;
    import edu.stanford.nlp.util.CoreMap;
    import java.util.Collection;
    import java.util.Properties;
    
    /**
     * A demo illustrating how to call the OpenIE system programmatically.
     */
    
    public class OpenIEDemo {
    
      public static void main(String[] args) throws Exception {
        // Create the Stanford CoreNLP pipeline
        Properties props = new Properties();
        props.setProperty("annotators", "tokenize,ssplit,pos,lemma,depparse,parse,natlog,openie");
        StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
    
        // Annotate an example document.
        Annotation doc = new Annotation("Obama was born in Hawaii. He is our president.");
        pipeline.annotate(doc);
    
        // Loop over sentences in the document
        for (CoreMap sentence : doc.get(CoreAnnotations.SentencesAnnotation.class)) {
          // Get the OpenIE triples for the sentence
          Collection<RelationTriple> triples = sentence.get(NaturalLogicAnnotations.RelationTriplesAnnotation.class);
          // Print the triples
          for (RelationTriple triple : triples) {
            System.out.println(triple.confidence + "\t" +
                triple.subjectLemmaGloss() + "\t" +
                triple.relationLemmaGloss() + "\t" +
                triple.objectLemmaGloss());
          }
        }
      }
    }
    

0 个答案:

没有答案