我安装时使用的是windows系统,python 3.7:
import nltk
nltk.download('reuters')
导入没问题,我也已经在我的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()
它有一些错误,我不知道如何修复它......但是,代码在我的 MacBook 上运行良好我想知道我使用 anaconda 的 windows 系统 ps 发生了什么,而在 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'