簡單記錄一下,如何使用 Standford Corenlp 這個工具
建置環境:Anaconda
- 安裝 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