登录    |    注册

NLTK--collocations 模块

2021-02-21 13:49:07

在语料库中识别搭配的工具——通常连续出现的单词。它们也可用于查找单词出现之间的其他关联。

寻找搭配需要首先计算单词的频率和它们在其他单词上下文中的出现。通常情况下,单词的集合将需要过滤以只保留有用的内容术语。然后,每个词的ngram都可以根据某种关联度量进行评分,以确定每个ngram作为搭配的相对可能性。

这个 BigramCollocationFinder 和 TrigramCollocationFinder 类提供这些功能,取决于提供的函数在给定适当的频率计数的情况下对NGRAM进行评分。在bigram_度量和trigram_度量中提供了许多标准关联度量。

class nltk.collocations.BigramCollocationFinder(word_fdbigram_fdwindow_size=2)[源代码]

基类:nltk.collocations.AbstractCollocationFinder

用于查找和排序bigram搭配或其他关联度量的工具。使用from_Words()而不是直接构造实例通常很有用。

default_ws = 2
classmethod from_words(wordswindow_size=2)[源代码]

为给定序列中的所有大图构造一个BigramCollocationInder。当窗口大小大于2时,以教堂样式和汉克斯(1990)的关联比率计算非连续的大括号。

score_ngram(score_fnw1w2)[源代码]

使用给定的计分函数返回给定bigram的分数。在Church和Hanks(1990)之后,计数按1/(窗口大小-1)的系数进行缩放。

class nltk.collocations.QuadgramCollocationFinder(word_fdquadgram_fdiiiiiixiixxiiixiixii)[源代码]

基类:nltk.collocations.AbstractCollocationFinder

用于查找和排序四图搭配或其他关联度量的工具。使用from_Words()而不是直接构造实例通常很有用。

default_ws = 4
classmethod from_words(wordswindow_size=4)[源代码]
score_ngram(score_fnw1w2w3w4)[源代码]
class nltk.collocations.TrigramCollocationFinder(word_fdbigram_fdwildcard_fdtrigram_fd)[源代码]

基类:nltk.collocations.AbstractCollocationFinder

用于查找和排序三角搭配或其他关联度量的工具。使用from_Words()而不是直接构造实例通常很有用。

bigram_finder()[源代码]

使用该查找器中的bigram和unigram数据构造bigram并置查找器。请注意,这不包括应用于此查找器的任何筛选。

default_ws = 3
classmethod from_words(wordswindow_size=3)[源代码]

为给定序列中的所有三元构造一个三元配置标识。

score_ngram(score_fnw1w2w3)[源代码]

使用给定的得分函数返回给定三角图的得分。

想要了解NLTK,请点击这里

想要了解安装NLTK,请点击这里