中文NLP工具

中文NLP工具

1 HanLP

HanLP(汉语言处理包)是一款开源的使用Java进行开发的中文自然语言处理工具,提供的功能包括中文分词、词性标注、命名实体识别、依存句法分析等。
该工具包目前仍处在更新维护中(2017.9最新版本是1.3.4)
github仓库:https://github.com/hankcs/HanLP
开发语言:Java
支持语言:Java,如果使用Python,可以借助JPype

配置和使用:可以参加github地址
关键点:修改配置文件hanlp.propertiesroot=,可以使用相对或绝对地址,并且该文件需放置在bin目录中。

2 复旦 FundanNLP

FudanNLP (FNLP)是复旦大学开发的中文自然语言处理工具包,目前暂时停止了更新(目前最新是2016年的微调整,主体版本2.00(2014.3.25)),另:FNLP官方博客:[http://fnlp.org]已失踪;支持中文分词、词性标注、命名实体识别。
github仓库:https://github.com/FudanNLP/fnlp
开发语言:Java
支持语言:Java
安装配置:github wiki;需要先配置maven,手动进行编译得到jar包。

3 哈工大 HIT LTP

LPT(Language Technology Platform)是哈尔滨工业大学开发的中文自然语言处理工具。目前最新版本是3.3.2(2016年,目前基本暂时停止更新,模型最新是3.3.1)。代码开源,商业使用付费。支持中文分词、词性标注、命名实体识别、依存句法分析、语言角色标注(中文)
github地址:https://github.com/HIT-SCIR/ltp
开发语言:C++
支持语言:Python(pyltp), Java(ltp4j)

Java开发中配置:
首先使用CMake+VS编译C++源代码得到库文件,然后使用ant构建,生成ltp4j.jar包。注意要保证C++编译的库文件和ltp4j.jar架构版本都是64位或32位。

补充:

  • 哈工大LTP编译使用
  • Java调用哈工大LTP接口(JNI方式实现)

4 清华 THU LAC

THULAC (THU Lexical Analyzer for Chinese) 是由清华大学自然语言处理与社会人文计算实验室研制推出的一套中文词法分析工具包,具有中文分词和词性标注功能。

github地址:

  • https://github.com/thunlp/THULAC (C++)
  • https://github.com/thunlp/THULAC-Java (适用于命令行)
  • https://github.com/thunlp/THULAC-Python

Java版本(thulac4j):
https://github.com/yizhiru/thulac4j
thulac4j是THULAC的高效Java 8实现,具有分词速度快、准、强的特点;

如果使用Java开发,推荐直接使用thulac4j,语言模型可以直接下载thulac4j处理后的数据,或使用ThuLac的模型进行生产:

ThulacModel thulac = new ThulacModel("cws_model.bin", "cws_dat.bin", "cws_label.txt");
thulac.serialize("seg_only.bin");

ThulacModel thulac = new ThulacModel("model_c_model.bin", "model_c_dat.bin", "model_c_label.txt");
thulac.serialize("seg_pos.bin");

thulac4j 打包得到jar包,同时还需要相关的包(maven dependencies中可以查看):

kryo-4.0.0.jar, reflectasm-1.11.3.jar, asm-5.0.4.jar, minlog-1.3.0.jar, objenesis-2.2.jar

另:
Simplifier和StopFilter,如需要正常执行,需要在打包成jar时,将models中文件一同打包。
程序实力可是参照test中的程序。

5 (中科院)NLPIR (原ICTCLAS)

  • https://github.com/NLPIR-team/NLPIR
  • http://ictclas.nlpir.org/

6 斯坦福 Stanford CoreNLP(多语言)

  • https://nlp.stanford.edu/software/

中文的示例:

Properties props = new Properties();
props.load(IOUtils.readerFromString(file)); // file是配置文件,从中的jar中提出处理
props.setProperty("annotators", "tokenize, ssplit, pos, lemma"); // 修改默认设置,这里去除了parser等部分
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
Annotation document = new Annotation(text);
pipeline.annotate(document);

List sentences = document.get(SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
    for (CoreLabel token : sentence.get(TokensAnnotation.class)) {
        String word = token.get(TextAnnotation.class); # 分词后的词
        String pos = token.get(PartOfSpeechAnnotation.class); # 词性标记
        String ne = token.get(NamedEntityTagAnnotation.class); # NER类别
        System.out.println(word + "\t| " + pos + "\t| " + ne);
    }
    Tree tree = sentence.get(TreeAnnotation.class);
    System.out.println("\n语法树:\n" + tree.toString());
}

你可能感兴趣的:(中文NLP工具)