失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > Stanford CoreNLP 中文自定义词典

Stanford CoreNLP 中文自定义词典

时间:2023-04-15 04:50:07

相关推荐

Stanford CoreNLP 中文自定义词典

Stanford CoreNLP 中文自定义词典

启动服务

参考文档,感谢前人探路

DocCSDN深入浅出 Stanford NLP(深入篇)

下载

CoreNLP的源码git下载chinese模型jar包,解压到src

用ant导入build.xml,Eclipse-File-New-Other-Java-Java Project from Existing Ant Buildfile

启动服务,总是没法找到standordCoreNLP-chinese.properties

Configuration设置参数-serverProperties edu/stanford/nlp/pipeline/StanfordCoreNLP-chinese.properties

修改IOUtils.java 472行getInputStreamFromURLOrClasspathOrFileSystem

try {String base = IOUtils.class.getResource("/").getPath();if (textFileOrUrl.indexOf("/")!=0) {textFileOrUrl = base +textFileOrUrl;//资源文件根目录+需要寻找到文件位置}in = findStreamInClasspathOrFileSystem(textFileOrUrl);}

debug后发现并没有载入properties中的模型,修改StanfordCoreNLPServer.java中的78行

这样启动服务的时候就会载入模型

protected static String preloadedAnnotators = "tokenize, ssplit, pos, lemma, ner, depparse, coref, natlog, openie";

从edu.stanford.nlp.pipeline 运行 StanfordCoreNLPServer.java,localhost:9000

加入新词生成词典

加入自定义词语,重新生成词典

下载Chinese word segmenter,解压

添加词典

java -cp "*" -mx1g edu.stanford.nlp.wordseg.ChineseDictionary -inputDicts my_dict.txt,dict-chris6.ser.gz -output new_dict.ser.gz

To do:打包

Compile the code with this command:cd CoreNLP ; ant

Then run this command to build a jar with the latest version of the code:cd CoreNLP/classes ; jar -cf ../stanford-corenlp.jar edu

java -Xmx8g -cp "*" -Djava.io.tmpdir=/your/path/tmp edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-chinese.properties -port 6668

如果觉得《Stanford CoreNLP 中文自定义词典》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。