基于NLTK搭建stanford parser環(huán)境
首先需要下載:stanford-parser
網(wǎng)盤鏈接:網(wǎng)盤鏈接
提取碼:x9wz
如果需要最新版可以去官網(wǎng)下載:https://nlp.stanford.edu/software/lex-parser.shtml
解壓之后會發(fā)現(xiàn)并沒有englishPCFG.ser.gz這個文件。
不要著急,englishPCFG.ser.gz這個文件其實(shí)就在stanford-parser-3.6.0-models.jar文件中,可以將其解壓出來。
使用方法:
from nltk.parse.stanford import StanfordParser stanford_parser_dir = r'E:\tools\stanfordNLTK\stanford-parser-full-2015-12-09' eng_model_path = "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz" my_path_to_models_jar = stanford_parser_dir + "\stanford-parser-3.6.0-models.jar" my_path_to_jar = stanford_parser_dir + "\stanford-parser.jar" parser = StanfordParser(model_path=eng_model_path, path_to_models_jar=my_path_to_models_jar, path_to_jar=my_path_to_jar) print(list(parser.parse("the quick brown fox jumps over the lazy dog".split())))
1
2
3
4
5
6
7
8
9
10
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時內(nèi)刪除侵權(quán)內(nèi)容。