http://nlp.stanford.edu/software/segmenter.shtmlhtml
斯坦福大学的分词器,该系统须要JDK 1.8+,从上面连接中下载stanford-segmenter-2014-10-26,解压以后,以下图所示java
,进入data目录,其中有两个gz压缩文件,分别是ctb.gz和pku.gz,其中CTB:宾州大学的中国树库训练资料 ,PKU:中国北京大学提供的训练资料。固然了,你也能够本身训练,一个训练的例子能够在这里面看到http://nlp.stanford.edu/software/trainSegmenter-20080521.tar.gzapache
http://nlp.stanford.edu/software/CRF-NER.shtmlapp
斯坦福NER是采用Java实现,能够识别出(PERSON,ORGANIZATION,LOCATION),使用本软件发表的研究成果需引用下述论文:ide
Jenny Rose Finkel, Trond Grenager, and Christopher Manning. 2005. Incorporating Non-local Information into Information Extraction Systems by Gibbs Sampling. Proceedings of the 43nd Annual Meeting of the Association for Computational Linguistics (ACL 2005), pp. 363-370. 测试
下载地址在:ui
http://nlp.stanford.edu/~manning/papers/gibbscrf3.pdfspa
在NER页面能够下载到两个压缩文件,分别是stanford-ner-2014-10-26和stanford-ner-2012-11-11-chinese.net
将两个文件解压可看到orm
,默认NER能够用来处理英文,若是须要处理中文要另外处理。
Included with Stanford NER are a 4 class model trained for CoNLL, a 7 class model trained for MUC, and a 3 class model trained on both data sets for the intersection of those class sets.
3 class: | Location, Person, Organization |
4 class: | Location, Person, Organization, Misc |
7 class: | Time, Location, Organization, Person, Money, Percent, Date |
如上图能够看到针对英文提供了3class、4class、7class,http://nlp.stanford.edu:8080/ner/ 可是中文并无,这是一个在线演示的地址,能够上去瞧瞧 。
在Eclipse中新建一个Java Project,将data目录拷贝到项目根路径下,再把stanford-ner-2012-11-11-chinese解压的内容所有拷贝到classifiers文件夹下,将stanford-segmenter-3.5.0加入到classpath之中,将classifiers文件夹拷贝到项目根目录,将stanford-ner-3.5.0.jar和stanford-ner.jar加入到classpath中。最后,去http://nlp.stanford.edu/software/corenlp.shtml下载stanford-corenlp-full-2014-10-31,将解压以后的stanford-corenlp-3.5.0也加入到classpath之中。最后的Eclipse中结构以下:
根据
We also provide Chinese models built from the Ontonotes Chinese named entity data. There are two models, one using distributional similarity clusters and one without. These are designed to be run on word-segmented Chinese. So, if you want to use these on normal Chinese text, you will first need to run Stanford Word Segmenter or some other Chinese word segmenter, and then run NER on the output of that!
这段说明,很清晰,须要将中文分词的结果做为NER的输入,而后才能识别出NER来。
同时便于测试,本Demo使用junit-4.10.jar,下面开始上代码
view plaincopy to clipboardprint?
|
view plaincopy to clipboardprint?
|
注意必定是JDK 1.8+的环境,最后输出结果以下
loading dictionaries from data/dict-chris6.ser.gz...Done. Unique words in ChineseDictionary is: 423200
done [23.2 sec].
serDictionary=data/dict-chris6.ser.gz
sighanCorporaDict=data
inputEncoding=UTF-8
sighanPostProcessing=true
INFO: TagAffixDetector: useChPos=false | useCTBChar2=true | usePKChar2=false
INFO: TagAffixDetector: building TagAffixDetector from data/dict/character_list and data/dict/in.ctb
Loading character dictionary file from data/dict/character_list
Loading affix dictionary from data/dict/in.ctb
segmented res: 2008年 9月 9日 新华网 9月 8日 信息 : ( 记者 张家伟 ) 澳门 特区 政府 卫生局 疾病 预防 及 控制 中心 8 日 表示 , 目前 累计 有 141 人 在 本地 自助 餐厅 进食 后 出现 食物 中毒 症状 , 其中 大部分 与 进食 “ 问题 生蚝 ” 有关 。 卫生局 最先 在 3 日 公布 说 , 有 14 名 来自 三 个 群体 的 港 澳 人士 8月 27日 至 30日 期间 在 澳门 金沙 酒店 用 餐后 出现 不适 , 患者 陆续 出现 发热 、 呕吐 和 腹泻 等类 诺沃克 样 病毒 感染 的 症状 。 初步 调查 显示 , “ 上述 状况 可能 和 进食 生蚝 有关 ” 。
2008 年 9月 9日 新华网 9月 8日 信息 : ( 记者 张家伟 ) 澳门 特区 政府 卫生局 疾病 预防 及 控制 中心 8 日 表示 , 目前 累计 有 141 人 在 本地 自助 餐厅 进食 后 出现 食物 中毒 症状 , 其中 大部分 与 进食 “ 问题 生蚝 ” 有关 。 卫生局 最先 在 3 日 公布 说 , 有 14 名 来自 三 个 群体 的 港 澳 人士 8月 27日 至 30日 期间 在 澳门 金沙 酒店 用 餐后 出现 不适 , 患者 陆续 出现 发热 、 呕吐 和 腹泻 等类 诺沃克 样 病毒 感染 的 症状 。 初步 调查 显示 , “ 上述 状况 可能 和 进食 生蚝 有关 ” 。
Loading classifier from E:\workspaces\EclipseEE4.4\aaaaaa\classifiers\chinese.misc.distsim.crf.ser.gz ... done [6.8 sec].
<MISC>2008 年 9月 9日 新华网 9月 8日</MISC> 信息 : ( 记者 <PERSON>张家伟</PERSON> ) <GPE>澳门</GPE> <LOC>特区</LOC> <ORG>政府 卫生局 疾病 预防 及 控制 中心</ORG> <MISC>8 日</MISC> 表示 , 目前 累计 有 141 人 在 本地 自助 餐厅 进食 后 出现 食物 中毒 症状 , 其中 大部分 与 进食 “ 问题 生蚝 ” 有关 。 <ORG>卫生局</ORG> 最先 在 3 日 公布 说 , 有 14 名 来自 <MISC>三</MISC> 个 群体 的 <GPE>港 澳</GPE> 人士 <MISC>8月 27日 至 30日</MISC> 期间 在 <GPE>澳门</GPE> 金沙 酒店 用 餐后 出现 不适 , 患者 陆续 出现 发热 、 呕吐 和 腹泻 等类 诺沃克 样 病毒 感染 的 症状 。 初步 调查 显示 , “ 上述 状况 可能 和 进食 生蚝 有关 ” 。
Complete!