Name ‘stopwords’ is not defined but I already import the package.

huangapple go评论104阅读模式
英文:

Name 'stopwords' is not defined but I already import the package

问题

NameError: name 'stopwords' is not defined

这是我的代码:

import nltk
import re
nltk.download('stopwords')
print(stopwords.words('english'))

拥有停用词列表。

英文:

I am trying to use stopwords, but I am getting this error:

NameError: name 'stopwords' is not defined

This is my code:

import nltk
import re
nltk.download('stopwords')
print(stopwords.words('english'))

Have the list of stopwords.

答案1

得分: 1

import nltk
from nltk.corpus import stopwords

stops = set(stopwords.words('english'))
print(stops)

英文:
import nltk
from nltk.corpus import stopwords

stops = set(stopwords.words('english'))
print(stops)

huangapple
  • 本文由 发表于 2023年3月1日 08:24:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75598557.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定