我已经看了几个答案,但他们总是只回答我的部分问题。我有一个否定词的向量和一个带有客户评论的数据框列。最终目标是通过为其组成单词分配情绪来为每个评论分配情绪。作为示例,评论"I was happy with the product"
对所有单词都有中立情绪,但"happy"
在这种情况下具有正面含义。现在我需要处理否定,因为他们几乎总是扭转情绪,所以之前的审查但负面情绪将是"I was not happy with the product"
。显然它可能比这更复杂。
假设我有一个否定词negations
的向量和reviews
的向量(数据帧列),我怎么能扫描评论并用所有否定词取代所有否定词,一个下划线和以下单词,以上示例最终将成为"I was not_happy with the product"
。这将允许我将否定的单词视为一个(当然我需要相应地调整我的情绪词语料库。注意实际的语言不是英语。我假设我需要一些复杂的正则表达式,可以引用匹配的否定但我'我不是正则表达式。
示例
negations <- c("not", "without", "never")
reviews <- c("I was happy", "I never asked", "I came without hope", "He did not help")
结果应该是
c("I was happy", "I never_asked", "I came without_hope", "He did not_help")
答案 0 :(得分:2)
您可以从<img class="bigBoutiqueImage lazy-load-trigger loaded"
**src="https://img-trendyol.mncdn.com//Assets/ProductImages/OA/CampaignVisual/OriginalBoutiqueImages/12640/4pu3yjc3_11_new.jpg"**
data-original="https://img-trendyol.mncdn.com//Assets/ProductImages/OA/CampaignVisual/OriginalBoutiqueImages/12640/4pu3yjc3_11_new.jpg"
title="Twigy - Yılbaşı Özel"
onerror="this.src='/Resources/images/bigBoutiquePlaceHolder.png'"
alt="Twigy - Yılbaşı Özel">
包中尝试此操作:
stringi