yanqiangmiffy / Chinese-LangChain

中文langchain项目|小必应,Q.Talk,强聊,QiangTalk
2.68k stars 323 forks source link

python main.py nltk错误 #30

Open horacehht opened 1 year ago

horacehht commented 1 year ago

Resource [93mpunkt[om not found.Please use the NLTK Downloader to obtain theresource: [31m>>> import nltk>>> nltk.download(' punkt')[omFor more information see: https://www.nltk.org/data.html NLTK's dat all"), or just tra and no gra Attempted to load [93mtokenizers/punkt/PY3/english.pickle[om Searched in:/home/horace/nltk data!/home/horace/.conda/envs/chatglm/nltk data!- '/home/horace/.conda/envs/chatglm/share/nltk data'/home/horace/.conda/envs/chatglm/lib/nltk data' '/usr/share/nltk data' '/usr/local/share/nltk data ‘/usr/lib/nltk data’ ‘/usr/local/lib/nltk data’

终端中提示我import nltk后使用nltk.download('punkt'),但执行这条命令会失败。查询资料后去官网下载,解压后放到上述提到的指定位置,再运行main.py,发现还是出现这个错误。不知道怎么解决

horacehht commented 1 year ago

解决了。需要在nltk_data目录中再创建一个tokenizers目录,然后把punkt放到tokenizers目录里面。 等会有个averaged_perceptron_tagger,也需要这样子操作。手动下载,然后在nltk_data下面新建一个taggers目录,然后把averaged_perceptron_tagger放到taggers下面。