【问题标题】:I want to drop a specific term from the sentimentr package so that it does not impact the overall sentiment score我想从感测器包中删除一个特定术语,这样它就不会影响整体情绪得分
【发布时间】:2020-05-16 06:11:31
【问题描述】:

例如,我有一行文字“我感谢您的帮助” 我想从情感词典中删除“欣赏”这个词,这样它就不会影响未来的任何情感得分。

【问题讨论】:

    标签: r sentimentr


    【解决方案1】:

    您可以创建自己的情绪表。从头开始或使用默认设置。

    例子:

    library(sentimentr)
    
    txt <- "i appreciate the help"
    sentiment(txt)
       element_id sentence_id word_count sentiment
    1:          1           1          4      0.25
    

    调整情绪表。由于情绪表存储为 data.tables,因此首先加载 data.table。

    library(data.table)
    
    # remove word we do not want from default sentiment table coming from lexicon package
    my_sent_table <- lexicon::hash_sentiment_jockers_rinker[x != "appreciate"]
    
    sentiment(txt, polarity_dt =  my_sent_table)
       element_id sentence_id word_count sentiment
    1:          1           1          4         0
    

    【讨论】:

      猜你喜欢
      • 2019-01-03
      • 2019-04-13
      • 1970-01-01
      • 1970-01-01
      • 2018-08-06
      • 2017-07-30
      • 1970-01-01
      • 2021-05-01
      • 2012-02-25
      相关资源
      最近更新 更多