我喜欢做一个关于酒店评论的小情绪分析。你知道吗
示例(stop\u word\u filter:
[“偶数”、“尽管”、“图片”、“显示”、“干净”、“房间”、“实际”、“房间”、“退出”、“脏”、“过期”、“同时”、“检查”、“15”、“时钟”、“房间”、“未”、“准备好”、“时间”]
我发现这是关于“旅馆”和“干净”的。我想把“否定”和“干净”联系起来,后者应该是“脏的”。 我整合了一个否定词列表。 我正在等待执行。。。你知道吗
代码:
bullets = [] #output
distances = []
bad_word_locations = []
rubrik_word_location = [] #category_word
#if there is a category word in the review
if len(rubrik_uR_list) == 1:
#get the index of that one
rubrik_word_location = stop_words_filter.index(rubrik_uR_list[0])
#go throu all negative words and if one of them in my sentence get the index of that word
for w in negativ_words_list:
if w in stop_words_filter:
bad_word_locations.append(stop_words_filter.index(w))
#NOW ITS GETTING CRUCIAL
#if we found one
if len(bad_word_locations) > 0:
#I need to some how catch now the closest word, my code is not doing this
distances.append(abs(rubrik_word_location-bad_word_locations[0]))
bullets.append(stop_words_filter[min(distances)])
#if I got more categories in one review I need to remind that somehow...
blacklist.append(stop_words_filter[min(distances)])
我明白了,我编程很差。 我将衷心感谢你的帮助。你知道吗
提前谢谢你,尼克拉斯
我自己就知道了。你知道吗
祝你好运,尼克拉斯
相关问题 更多 >
编程相关推荐