{"id":235640,"date":"2022-02-20T10:25:29","date_gmt":"2022-02-20T02:25:29","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=235640"},"modified":"2022-02-15T13:25:17","modified_gmt":"2022-02-15T05:25:17","slug":"core-nlp-example","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/core-nlp-example.html","title":{"rendered":"Ubuntu\u4e0b\u5b89\u88c5Stanford CoreNLP"},"content":{"rendered":"
Stanford CoreNLP\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u81ea\u7136\u8bed\u8a00\u5206\u6790\u5de5\u5177\u3002\u5b83\u80fd\u591f\u7ed9\u51fa\u57fa\u672c\u7684\u8bcd\u5f62\uff0c\u8bcd\u6027\uff0c\u4e0d\u7ba1\u662f\u516c\u53f8\u540d\u8fd8\u662f\u4eba\u540d\u7b49\uff0c\u683c\u5f0f\u5316\u7684\u65e5\u671f\uff0c\u65f6\u95f4\uff0c\u91cf\u8bcd\uff0c\u5e76\u4e14\u80fd\u591f\u6807\u8bb0\u53e5\u5b50\u7684\u7ed3\u6784\uff0c\u8bed\u6cd5\u5f62\u5f0f\u548c\u5b57\u8bcd\u4f9d\u8d56\uff0c\u6307\u660e\u90a3\u4e9b\u540d\u5b57\u6307\u5411\u540c\u6837\u7684\u5b9e\u4f53\uff0c\u6307\u660e\u60c5\u7eea\uff0c\u63d0\u53d6\u53d1\u8a00\u4e2d\u7684\u5f00\u653e\u5173\u7cfb\u7b49\u3002<\/p>\n
<\/p>\n
\u5f88\u591a\u81ea\u7136\u8bed\u8a00\u5904\u7406\u7684\u4efb\u52a1\u90fd\u9700\u8981stanfordcorenlp\u5c06\u8fdb\u884c\u6587\u672c\u5904\u7406\u3002\u5728Linux\u73af\u5883\u4e0b\u5b89\u88c5stanfordcorenlp\u4e5f\u6bd4\u8f83\u7b80\u5355\u3002<\/p>\n
\u9996\u5148\u9700\u8981\u5b89\u88c5Java\u8fd0\u884c\u73af\u5883\uff0c\u4ee5Ubuntu 12.04\u4e3a\u4f8b\uff0c\u5b89\u88c5Java\u8fd0\u884c\u73af\u5883\u4ec5\u9700\u8981\u4e24\u6b65\uff1a<\/p>\n
sudo apt-get install default-jre\r\nsudo apt-get install default-jdk12<\/pre>\n\u7136\u540e\u4e0b\u8f7dStanford coreNLP \u5305\uff1a<\/p>\n
wget http:\/\/nlp.stanford.edu\/software\/stanford-corenlp-full-2018-02-27.zip\r\nunzip stanford-corenlp-full-2018-02-27.zip\r\ncd stanford-corenlp-full-2018-02-27\/12345<\/pre>\n\u4e5f\u53ef\u4ee5\u53bbstanford corenlp\u7684\u5b98\u7f51\u4e0a\u53bb\u4e0b\u8f7d\u5b89\u88c5\u5305\uff0cwindows\u8ddflinux\u4e0b\u90fd\u662f\u4e00\u6837\u7684\u3002<\/p>\n
\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1a
\n\u6211\u4eec\u9700\u8981Stanford corenlp\u6765\u628a\u6570\u636e\u5206\u8bcd\u3002
\n\u628a\u4e0b\u5217\u8fd9\u884c\u4ee3\u7801\u52a0\u5230\u4f60\u7684.bashrc\u91cc\u9762(vim .bashrc)<\/p>\nexport CLASSPATH=\/path\/to\/stanford-corenlp-full-2018-02-27\/stanford-corenlp-3.9.1.jar1<\/pre>\n\u628a\/path\/to\/\u66ff\u6362\u4e3a\u4f60\u4fdd\u5b58stanford-corenlp-full-2016-10-31\u7684\u5730\u65b9\u7684\u8def\u5f84
\n\u5b89\u88c5\uff1a<\/p>\nsudo pip3 install stanfordcorenlp1<\/pre>\n\u8fd9\u91cc\u5982\u679c\u4f60\u4f7f\u7528python2\uff0c\u5c31\u9700\u8981<\/p>\n
sudo pip2 install stanfordcorenlp1<\/pre>\n\u5904\u7406\u4e2d\u6587\u8fd8\u9700\u8981\u4e0b\u8f7d\u4e2d\u6587\u7684\u6a21\u578bjar\u6587\u4ef6\uff0c\u7136\u540e\u653e\u5230stanford-corenlp-full-2018-02-27\u6839\u76ee\u5f55\u4e0b\u5373\u53ef<\/p>\n
wget http:\/\/nlp.stanford.edu\/software\/stanford-chinese-corenlp-2018-02-27-models.jar1<\/pre>\n\u5982\u4f55\u68c0\u67e5\u81ea\u5df1\u662f\u5426\u88c5\u597d\u4e86stanfordcorenlp
\n\u8fdb\u5165python2\u6216\u8005python3<\/p>\npython2\r\nfrom stanfordcorenlp import StanfordCoreNLP123<\/pre>\n\u80fd\u6210\u529f\u5bfc\u5165\u4e0d\u62a5\u9519\uff0c\u5c31\u662f\u5b89\u88c5\u6210\u529f\u4e86\u3002
\n\u6700\u540e\u68c0\u67e5\u662f\u5426\u80fd\u6b63\u5e38\u4f7f\u7528\uff1a
\n\u8fd0\u884c\u4e0b\u5217\u4ee3\u7801\uff1a<\/p>\necho \"Please tokenize this text.\" | java edu.stanford.nlp.process.PTBTokenizer1<\/pre>\n\u4f60\u4f1a\u770b\u5230\u4e0b\u5217\u8f93\u51fa\uff1a<\/p>\n
Please\r\ntokenize\r\nthis\r\ntext\r\n.\r\nPTBTokenizer tokenized 5 tokens at 68.97 tokens per second.123456<\/pre>\n\u8fd9\u6837\u5c31\u5b89\u88c5\u6210\u529f\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
Stanford CoreNLP\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u81ea\u7136\u8bed\u8a00\u5206\u6790\u5de5\u5177\u3002\u5b83\u80fd\u591f\u7ed9\u51fa\u57fa\u672c\u7684\u8bcd\u5f62\uff0c\u8bcd\u6027\uff0c\u4e0d\u7ba1\u662f\u516c\u53f8\u540d\u8fd8\u662f\u4eba\u540d […]<\/p>\n","protected":false},"author":310,"featured_media":235648,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-235640","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/235640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/310"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=235640"}],"version-history":[{"count":10,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/235640\/revisions"}],"predecessor-version":[{"id":235833,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/235640\/revisions\/235833"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/235648"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=235640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=235640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=235640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}