簡體   English   中英

如何在Stanford CoreNLP中選擇共指解析系統

[英]How to choose Coreference resolution system in Stanford CoreNLP

我正在嘗試從core-nlp測試共指解析系統。 通過對原始文本運行共指解析 ,可以理解為'dcoref系統'設置常規屬性。

我想根據模塊的延遲在共參考系統[確定性,統計性,神經性]之間進行選擇。 命令行用法對我來說很清楚,我如何使用此選項作為API?

目前,我正在運行默認代碼:

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);
       }
    }

W'll,挖出后corefProperties.class我發現需要修改的屬性。

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

但是,更令人驚訝的是執行上述示例測試文本。 Statistical method大約需要45秒,而Neural Statistical method大約需要30秒。 (Intel i5 @ 2.00Ghz,8GB內存)。 我在這里想念什么嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM