NLP设置相关问题, since 2021-03-20

(2021.03.20 Sat)

  • NLTK下载各类语料库的方法(windows版):
>> import nltk
>> nltk.download()
showing info https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml

遇到无法下载的情况,如提示error getaddrinfofailed(),采用如下解决办法:

  1. nltk.download()指令返回的提示链接https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml往往无法打开,这时在打开C:\Windows\System32\drivers\etc路径下的hosts文件,在结尾添加
ip_address raw.githubusercontent.com 

其中的ip_address是raw.githubusercontent.com的ip地址,可通过https://githubusercontent.com.ipaddress.com/raw.githubusercontent.com查询,比如在2021年3月21日,查询到的ip地址是185.199.108.133, 185.199.109.133, 185.199.110.133, 185.199.111.133。可使用其中任何一个代替ip_address,比如

185.199.108.133 raw.githubusercontent.com

并保存hosts文件。再次运行nltk.download()即可下载各类语料库。

  1. 在NLTK downloader的server index一栏中填入http://www.nltk.org/nltk_data/,NLTK的官网数据页面链接,随后refresh和download即可实现数据的下载。
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容