Shi*_* Wu 3 python nlp nltk reuters
我使用的是windows系统,安装时python 3.7:
import nltk
nltk.download('reuters')
Run Code Online (Sandbox Code Playgroud)
导入没有问题,而且我也已经在我的cmd中安装了nltk
但是当我执行代码时:
import matplotlib.pyplot as plt
from collections import Counter
from nltk.corpus import reuters
import re
import spacy
nlp = spacy.load('en', disable=['parser', 'tagger'])
reuters_fileids = reuters.fileids()
reuters_nlp = [nlp(re.sub('\s+',' ', reuters.raw(i)).strip()) for i in reuters_fileids[:100]]
label_counter = Counter()
Run Code Online (Sandbox Code Playgroud)
它有一些错误,我不知道如何修复它...但是,代码在我的 MacBook 上运行良好我想知道 Windows 系统发生了什么事 ps 我使用 anaconda,在 Windows 计算机上, anaconda 安装在 E:\
Resource reuters not found.
Please use the NLTK Downloader to obtain the resource:
>>> import nltk
>>> nltk.download('reuters')
Searched in:
- 'C:\\Users\\user/nltk_data'
- 'C:\\nltk_data'
- 'D:\\nltk_data'
- 'E:\\nltk_data'
- 'E:\\Anaconda\\nltk_data'
- 'E:\\Anaconda\\share\\nltk_data'
- 'E:\\Anaconda\\lib\\nltk_data'
- 'C:\\Users\\user\\AppData\\Roaming\\nltk_data'
Run Code Online (Sandbox Code Playgroud)
Var*_*ati 10
解压你的文件。您可以在 google colab 中使用以下命令,其中 -d 之后的相对路径将给出文件应解压缩的位置。
unzip /root/nltk_data/corpora/reuters.zip -d /root/nltk_data/corpora
Run Code Online (Sandbox Code Playgroud)