Stanford nlp 如何在斯坦福CoreNLP 3.5.2中使用中文共同参考?

Stanford nlp 如何在斯坦福CoreNLP 3.5.2中使用中文共同参考?,stanford-nlp,Stanford Nlp,斯坦福大学CoreNLP 3.5.2已出炉,并包括中文共同参考 我如何使用中文共同参考?它只包含一个文件“zh attributes.txt.gz” 谢谢 dev要在纯文本上运行,请确保类路径上有与中文相关的模型,然后尝试以下操作: String text = "Your text here"; String[] args = new String[]{ "-props", "edu/stanford/nlp/hcoref/properties/zh-dcoref-defau

斯坦福大学CoreNLP 3.5.2已出炉,并包括中文共同参考 我如何使用中文共同参考?它只包含一个文件“zh attributes.txt.gz”

谢谢


dev

要在纯文本上运行,请确保类路径上有与中文相关的模型,然后尝试以下操作:

String text = "Your text here"; String[] args = new String[]{ "-props", "edu/stanford/nlp/hcoref/properties/zh-dcoref-default.properties" }; Annotation document = new Annotation(text); Properties props = StringUtils.argsToProperties(args); StanfordCoreNLP corenlp = new StanfordCoreNLP(props); corenlp.annotate(document); HybridCorefAnnotator hcoref = new HybridCorefAnnotator(props); hcoref.annotate(document); Map corefChain = document.get(CorefChainAnnotation.class); System.out.println(corefChain); String text=“此处的文本”; 字符串[]args=新字符串[]{ “-props”,“edu/stanford/nlp/hcoref/properties/zh dcoref default.properties” }; 注释文档=新注释(文本); Properties props=StringUtils.args属性(args); StanfordCoreNLP corenlp=新的StanfordCoreNLP(道具); 核心说明(文件); HybridCoreFarnotator hcoref=新的HybridCoreFarnotator(道具); hcoref.注释(文件); Map corefChain=document.get(CorefChainAnnotation.class); System.out.println(corefChain);
此外,我们还有关于如何在CoNLL 2012数据上运行的文档

谢谢!我有新型号的! 当我运行示例时,说lost“demonyms.txt”,然后将“stanford-corenlp-3.5.2-models/edu/standford/nlp/modeles/dcoref/”复制到“stanford-chinese-corenlp-2015-04-20-models/edu/standford/nlp/modeles/dcoref/”, 然后
code
[凯特, 发, 了, 一, 封, 邮件, 给, 斯坦福, ,, 他, 没有, 收到, 回复, 。] 装载筛:中国人头匹配。。。 装载筛:精确匹配。。。 装载筛:精密结构。。。 装载筛:1。。。 装料筛:2。。。 装料筛:3。。。 装料筛:4。。。 装载筛:匹配。。。 语义未加载 使用annotators=lemma,ner忽略指定的注释器 在类edu.stanford.nlp.pipeline.chineseseSegmenterNotator中注册注释器段 添加注释引理 添加注释器 无效的
code

大家好,我们刚刚发布了一些新版本的3.5.2 jars,其中有一些补丁,我想把这个答案留给大家

如果您访问:

下载Stanford CoreNLP 3.5.2和相应的“中文模型”(文件名为Stanford-chinese-CoreNLP-2015-04-20-models.jar),您将拥有运行中文共同参考所需的jar

类路径中需要stanford-corenlp-3.5.2.jar、stanford-corenlp-3.5.2-models.jar和stanford-chinese-corenlp-2015-04-20-models.jar

您也可以从Maven上的stanford corenlp项目中获得完全相同的jar。我们刚刚发布了Maven上的中文模型jar。下面是如何将其添加到pom.xml中:

<dependency>
    <groupId>edu.stanford.nlp</groupId>
    <artifactId>stanford-corenlp</artifactId>
    <version>3.5.2</version>
   <classifier>models-chinese</classifier>
</dependency>

edu.stanford.nlp
斯坦福大学科伦普
3.5.2
中国模特
为了给您提供剪切和粘贴的内容,下面提供了肖编写的测试类代码以及所需的导入。我省略了示例中文文本,因此将字符串文本设置为要运行的示例中文文本

这应该使用如下命令运行:java-mx5g-cp“jars/*:”ChineseCorefTester-props edu/stanford/nlp/hcoref/properties/zh-dcoref-default.properties

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import edu.stanford.nlp.hcoref.CorefCoreAnnotations;
import edu.stanford.nlp.hcoref.CorefCoreAnnotations.CorefChainAnnotation;
import edu.stanford.nlp.hcoref.CorefSystem;
import edu.stanford.nlp.hcoref.data.CorefChain;
import edu.stanford.nlp.hcoref.data.CorefChain.CorefMention;
import edu.stanford.nlp.hcoref.data.Document;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.util.ArraySet;
import edu.stanford.nlp.util.CoreMap;
import edu.stanford.nlp.util.Generics;
import edu.stanford.nlp.util.IntTuple;
import edu.stanford.nlp.util.Pair;
import edu.stanford.nlp.util.StringUtils;
import java.io.*;
import java.util.*;
import edu.stanford.nlp.io.*;
import edu.stanford.nlp.ling.*;
import edu.stanford.nlp.pipeline.*;
import edu.stanford.nlp.trees.*;
import edu.stanford.nlp.trees.TreeCoreAnnotations.*;
import edu.stanford.nlp.util.*;

public class ChineseCorefTester {

    public static void main(String[] args) {

        String text = "<insert sample Chinese text here!>";
        Annotation document = new Annotation(text);
        Properties props = StringUtils.argsToProperties(args);
        StanfordCoreNLP corenlp = new StanfordCoreNLP(props);
        corenlp.annotate(document);
        HybridCorefAnnotator hcoref = new HybridCorefAnnotator(props);
        hcoref.annotate(document);
        System.out.println(document.get(CorefChainAnnotation.class));
    }
}
import java.util.ArrayList;
导入java.util.Collections;
导入java.util.List;
导入java.util.Map;
导入java.util.Properties;
导入java.util.Set;
导入edu.stanford.nlp.hcoref.corefcore注释;
导入edu.stanford.nlp.hcoref.corefcoreeannotations.CorefChainAnnotation;
导入edu.stanford.nlp.hcoref.CorefSystem;
导入edu.stanford.nlp.hcoref.data.CorefChain;
导入edu.stanford.nlp.hcoref.data.CorefChain.corefmotion;
导入edu.stanford.nlp.hcoref.data.Document;
导入edu.stanford.nlp.ling.core注释;
导入edu.stanford.nlp.ling.corelab;
导入edu.stanford.nlp.util.ArraySet;
导入edu.stanford.nlp.util.CoreMap;
导入edu.stanford.nlp.util.Generics;
导入edu.stanford.nlp.util.IntTuple;
导入edu.stanford.nlp.util.Pair;
导入edu.stanford.nlp.util.StringUtils;
导入java.io.*;
导入java.util.*;
导入edu.stanford.nlp.io.*;
导入edu.stanford.nlp.ling.*;
导入edu.stanford.nlp.pipeline.*;
导入edu.stanford.nlp.trees.*;
导入edu.stanford.nlp.trees.treeCorenotations.*;
导入edu.stanford.nlp.util.*;
公共级汉语教师{
公共静态void main(字符串[]args){
字符串文本=”;
注释文档=新注释(文本);
Properties props=StringUtils.args属性(args);
StanfordCoreNLP corenlp=新的StanfordCoreNLP(道具);
核心说明(文件);
HybridCoreFarnotator hcoref=新的HybridCoreFarnotator(道具);
hcoref.注释(文件);
System.out.println(document.get(CorefChainAnnotation.class));
}
}

3.5.2模型中没有“hcoref”目录:(谢谢!我在新模型中得到了它!当我运行示例时,说lost“demonyms.txt”,然后我将“stanford-corenlp-3.5.2-models/edu/standford/nlp/modeles/dcoref/”复制到“stanford-chinese-corenlp-2015-04-20-models/edu/standford/nlp/modeles/dcoref/”,1,根据上面的建议,我已经检查了好几次,但是没有出现正确的结果,它总是显示“{}”2,如何集成prop,包括分词、NER、parse和coref,我尝试了,但是没有正确的结果显示。根据模型中的目录,hcoref是一个单独的系统吗?@itdev你需要一个)新的中文corenlp模型文件,B)中文分段模型文件和C)类路径上的基本corenlp模型文件,用于加载所有相关资源。命名有点混乱,中文系统仍然是确定性的,但是其代码与hcoref包集成。谢谢,我可以运行示例,没有错误。但是,没有错误e结果也是如此;txten=“Kosgi Santosh向斯坦福大学发送了一封电子邮件。他没有得到回复。”凯特发了一封邮件给斯坦福大学,他没有收到回复."; 日志是:加载筛:StrictHeadMatch2…加载筛:StrictHeadMatch3…加载筛:StrictHeadMatch4…加载筛:代词匹配…语义未加载M