这是我的代码:
main
但是在运行代码时,出现此错误:
import java.util.ArrayList;
public class PasteClass {
public static void main(String[] args) {
Box a = new Box(20, 30, 40);
Box b = new Box(10, 20, 30);
ArrayList<Box> boxes = new ArrayList<>();
boxes.add(a);
boxes.add(b);
for (Box bx : boxes) {
bx.print();
}
}
}
如果我下载from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
example_sent = "This is a sample sentence, showing off the stop words filtration."
stop_words = set(stopwords.words('english'))
word_tokens = word_tokenize(example_sent)
filtered_sentence = [w for w in word_tokens if not w in stop_words]
filtered_sentence = []
for w in word_tokens:
if w not in stop_words:
filtered_sentence.append(w)
print(word_tokens)
print(filtered_sentence)
,则出现以下错误:
Resource stopwords not found.
Please use the NLTK Downloader to obtain the resource
谁能告诉我如何摆脱这个错误?
答案 0 :(得分:1)
这行吗?
import nltk
nltk.download('stopwords')
答案 1 :(得分:0)