Java调用Stanford coreNLP 做英文命名实体识别
1、gradle项目配置:
github地址:https://github.com/stanfordnlp/CoreNLP
需要事先下载官方训练好的模型并解压,地址:http://nlp.stanford.edu/software/stanford-corenlp-models-current.jar
需要用到的模型文件:
regexner_caseless.tab
english-left3words-distsim.tagger
english.all.3class.distsim.crf.ser.gz
注:compile依赖包可能需要其他多个,自行根据需要配置
repositories {
mavenLocal()
maven {
url = 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven {
url = 'https://mvnrepository.com/artifact/edu.stanford.nlp/stanford-corenlp'}
mavenCentral()
}
dependencies {
compile group: 'edu.stanford.nlp', name: 'stanford-corenlp', version: '4.0.0'
}
2、项目构建:
ner使用类edu.stanford.nlp.pipeline.NERCombinerAnnotator实现,主要流程为:分词、分句、词性标注、词干还原、实体提取。
standford coreNLP将文本处理过程用pipLine表示,即顺序串行,因此后续步骤依赖到前面步骤的结果(如词性标注需要先分词,需要注意步骤顺序)
主体调用代码:
package services.nerForEnglishEnt;
import edu.stanford.nlp.pipeline.*;
import java.io.IOException;
<

最低0.47元/天 解锁文章





