组合常见搭配的 NLP 流程

2024-03-18

我有一个语料库,我在 R 中使用 tm 包(并且还在 python 中的 NLTK 中镜像相同的脚本)。我正在使用一元组,但希望某种解析器能够将通常位于同一位置的单词组合成一个单词——即,我不想再在我的单词中分别看到“New”和“York”当它们一起出现时的数据集,并看到这个特定的对表示为“纽约”,就好像它是一个单词,并与其他一元词一起。

将有意义的常见 n 元语法转换为与一元语法相同的基础的过程称为什么?难道不是一件事吗?最后,什么会tm_map看起来像这个?

mydata.corpus <- tm_map(mydata.corpus, fancyfunction)

和/或在Python中?


我最近有一个类似的问题 https://stackoverflow.com/questions/42752356/create-a-dictionary-with-word-groups并尝试各种搭配

这是我选择识别搭配词对的解决方案:

from nltk import word_tokenize
from nltk.collocations import *

text = <a long text read in as string string>

tokenized_text = word_tokenize(text)

bigram_measures = nltk.collocations.BigramAssocMeasures(tokenized_text)
finder = BigramCollocationFinder.from_words()
scored = finder.score_ngrams(bigram_measures.raw_freq)

sorted(scored, key=lambda s: s[1], reverse=True)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

组合常见搭配的 NLP 流程 的相关文章

随机推荐