使用 Stanford Corenlp (中文) + Python

泥膩泥膩
3 min readNov 24, 2018
https://stanfordnlp.github.io/

簡單記錄一下,如何使用 Standford Corenlp 這個工具

建置環境:Anaconda

  1. 安裝 Java
$ conda install -c cyclus java-jdk

2. Stanford CoreNLP (Download Page) 文件

$ wget http://nlp.stanford.edu/software/stanford-corenlp-full-2018-10-05.zip
$ unzip stanford-corenlp-full-2018-10-05.zip
下載 chinese 的 jar 在目錄下$ cd stanford-corenlp-full-2018-10-05
$ wget http://nlp.stanford.edu/software/stanford-chinese-corenlp-2018-10-05-models.jar

3. 安裝

$ pip install stanfordcorenlp

4. Python 程式碼

# coding=utf-8from stanfordcorenlp import StanfordCoreNLPnlp = StanfordCoreNLP(r'/home/gld/stanford-corenlp-full-2016-10-31/', lang='zh')sentence = '今天天氣真好'
print nlp.word_tokenize(sentence)
print nlp.pos_tag(sentence)
print nlp.ner(sentence)
print nlp.parse(sentence)
print nlp.dependency_parse(sentence)

Output

--

--

泥膩泥膩
泥膩泥膩

Written by 泥膩泥膩

快解除我的封印RRRRRRRR~~~~

No responses yet