这是一个开始探索的巨大区域。
我强烈建议您查看 tidytextmining 书籍和软件包,以及作者的个人博客(https://juliasilge.com、http://varianceexplained.org),那里有大量出色的工作可以帮助您入门,而且真的非常适合 NLP 新手。
widyr 和 udpipe 库对您正在寻找的内容也很有帮助。
这里有几个例子:
使用 widyr,我们可以查看单词之间的成对 pmi,比如资金,以及与之有某种关系的所有其他单词。有关 PMI 的信息,请查看:https://stackoverflow.com/a/13492808/2862791
library(tidytext)
library(tidyverse)
texts <- tibble(text = c('This funding would help us create a new website and hire talented people',
'this random funding function talented people',
'hire hire hire new website funding',
'fun fun fun for all'))
tidy_texts %>%
pairwise_pmi(word, id) %>%
filter(item1 == 'funding') %>%
top_n(5, wt = pmi) %>%
arrange(desc(pmi))
item1 item2 pmi
<chr> <chr> <dbl>
1 funding this -0.0205
2 funding would -0.0205
3 funding help -0.0205
4 funding us -0.0205
因此,要介绍形容词和短语,您可以按照 boski 的建议查看 udpipe。
我也将重现上述内容来计算 PMI,因为它是一个非常直观且快速的计算指标
library(udpipe)
english <- udpipe_download_model(language = "english")
ud_english <- udpipe_load_model(english$file_model)
tagged <- udpipe_annotate(ud_english, x = texts$text)
tagged_df <- as.data.frame(tagged)
tagged_df %>%
filter(upos == 'ADJ' |
token == 'funding') %>%
pairwise_pmi(token, doc_id) %>%
filter(item1 == 'funding')
item1 item2 pmi
<chr> <chr> <dbl>
1 funding new 0.170
2 funding talented 0.170
您提到了 cleanNLP,它是用于此类工作的出色库。它使访问 udpipe 和 spacyr 以及其他一些方法变得容易,这些方法可以执行该形容词查找所需的标记化和标记。
如果您可以通过设置详细信息 spacyr 是我的首选,因为它最快,但如果速度不是问题,我会选择 udpipe,因为它非常易于使用。
我需要标记所有单词吗?如果是这样,我对短语进行分组不会有问题吗?
所以 udpipe 和其他文本注释器对此有解决方案。
在 udpipe 中,您可以使用 'keywords_collocation()' 来识别通过随机机会比预期更频繁地一起出现的单词。
我们需要一个比我上面写的三个垃圾句子更大的文本数据集才能获得可重现的示例。
但是您可以通过此博客了解很多信息:
https://bnosac.github.io/udpipe/docs/doc7.html
对不起,这个回复有点像链接的集合......但正如我所说,这是一个巨大的研究领域。