【发布时间】:2023-03-06 06:19:01
【问题描述】:
我只是在用 Python 对 NLP 进行一些研究,发现了一些奇怪的东西。
审查以下负面推文:
neg_tweets = [('I do not like this car', 'negative'),
('This view is horrible', 'negative'),
('I feel tired this morning', 'negative'),
('I am not looking forward to the concert', 'negative'),<---
('He is my enemy', 'negative')]
并通过删除停用词进行一些处理。
clean_data = []
stop_words = set(stopwords.words("english"))
for (words, sentiment) in pos_tweets + neg_tweets:
words_filtered = [e.lower() for e in words.split() if e not in stop_words]
clean_data.append((words_filtered, sentiment))
部分输出为:
(['i', 'looking', 'forward', 'concert'], 'negative')
我很难理解为什么停用词包括“不”,这会影响推文的情绪。
我的理解是停用词在情感方面没有价值。
那么,我的问题是为什么“不”包含在停用词列表中?
【问题讨论】:
-
主要是因为它们最常用于搜索和检索。这不是您的用例。
-
我不知道为什么,但我认为你可以这样做:take_out_not = set(('not')) stop_words = set(stopwords.words("english")) - take_out_not
-
停用词列表并非专门为情绪分析而设计的。在删除停用词之前,请自定义要删除的内容。例如,您可以手动从停用词列表中删除否定词。