【问题标题】:Removing all of the stop words in each tweet删除每条推文中的所有停用词
【发布时间】:2020-11-02 01:44:37
【问题描述】:

我想删除每条推文中的所有停用词,但是我在下面收到此错误。
我尝试寻找解决方案来解决它,但我没有找到任何解决方案。

stop_words = set(stopwords.words('english'))
print(stop_words)
nltk.download('punkt')
for all_words in words_in_tweet:
for a word in all_words:
#this is the error

File "<ipython-input-59-ade5bcf99259>", line 3
    for a word in all_words:
             ^
SyntaxError: invalid syntax

【问题讨论】:

  • 你只需要写for word in all_words:而不是for a word...

标签: python python-3.x jupyter-notebook data-mining sentiment-analysis


【解决方案1】:

As jdaz saidinvalid syntax错误可以通过修改修复

for a word in all_words:
    ...

for word in all_words:
    ...

【讨论】:

  • 尝试我收到此错误File "&lt;ipython-input-60-1de91e4ec2bb&gt;", line 3 for word in all_words: ^ SyntaxError: unexpected EOF while parsing
  • 我刚刚解决了这个问题,现在可以了,谢谢大家。
  • 如果我的回答有帮助,您能接受吗?干杯。
猜你喜欢
  • 1970-01-01
  • 2019-07-29
  • 1970-01-01
  • 2020-11-18
  • 1970-01-01
  • 2022-01-02
  • 1970-01-01
  • 2021-03-21
  • 1970-01-01
相关资源
最近更新 更多