【问题标题】:Excluding words in sentimentr排除感测器中的单词
【发布时间】:2020-02-03 17:35:16
【问题描述】:

如何从感伤者词典中删除多个术语?

例如,“请”和“建议”这两个词与积极情绪相关联,但我不希望这些特定词影响我的分析。

我已经想出一种方法,使用以下脚本排除 1 个单词,但需要排除更多:

mysentiment<- lexicon::hash_sentiment_jockers_rinker[x != "please"]

mytext <- c(
  'Hello, We are looking to purchase this material for a part we will be making, but your site doesnt state that this is RoHS complaint. Is it possible that its just not listed as such online, but it actually is RoHS complaint? Please advise. '
)

sentiment_by(mytext, polarity_dt = mysentiment)
extract_sentiment_terms(mytext,polarity_dt = mysentiment)

【问题讨论】:

    标签: r


    【解决方案1】:

    您可以子集 mysentiment data.table。只需创建一个您不希望包含的单词的向量并将其用于子集。

    mysentiment<- lexicon::hash_sentiment_jockers_rinker
    words_to_exclude <- c("please", "advise")
    mysentiment <- mysentiment [!x %in% words_to_exclude]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-07-27
      • 2018-08-24
      • 2012-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-30
      相关资源
      最近更新 更多