【问题标题】:How to score text tokens in a running total?如何在运行总计中对文本标记进行评分?
【发布时间】:2021-08-15 01:37:47
【问题描述】:

给定一张桌子:

text
The quick brown fox jumped over the lazy dogs
The cow jumped over the moon

还有一个标记和值的查找表:

keyword value
jumped 2
over the -1
cow 2

如何在 R 中构建一个函数来有效地记录一个短语出现的次数?

理想的结果是:

text score
The quick brown fox jumped over the lazy dogs 1
The cow jumped over the moon 3

通常我会使用 for 循环并一次遍历查找表一行,但我知道可能有更好的方法。我只是不知道它是什么。 (使用 tidyverse 的方式获得奖励积分!)

提前感谢您提供的任何链接或指导,您可以分享以提高效率!

【问题讨论】:

    标签: r nlp tidyverse


    【解决方案1】:

    解决方案是 unnest_tokens,然后与评分表进行联接。

    【讨论】:

      猜你喜欢
      • 2019-03-19
      • 2011-03-30
      • 1970-01-01
      • 2015-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多