class nltk.TrigramCollocationFinder(word_fd, bigram_fd, wildcard_fd, trigram_fd)[source]

A tool for the finding and ranking of trigram collocations or other association measures. It is often useful to use from_words() rather than constructing an instance directly.


__init__(word_fd, bigram_fd, wildcard_fd, ...) Construct a TrigramCollocationFinder, given FreqDists for appearances of words, bigrams, two words with any word between them, and trigrams.
above_score(score_fn, min_score) Returns a sequence of ngrams, ordered by decreasing score, whose scores each exceed the given minimum score.
apply_freq_filter(min_freq) Removes candidate ngrams which have frequency less than min_freq.
apply_ngram_filter(fn) Removes candidate ngrams (w1, w2, ...) where fn(w1, w2, ...) evaluates to True.
apply_word_filter(fn) Removes candidate ngrams (w1, w2, ...) where any of (fn(w1), fn(w2), ...) evaluates to True.
bigram_finder() Constructs a bigram collocation finder with the bigram and unigram data from this finder.
from_documents(documents) Constructs a collocation finder given a collection of documents, each of which is a list (or iterable) of tokens.
from_words(words[, window_size]) Construct a TrigramCollocationFinder for all trigrams in the given sequence.
nbest(score_fn, n) Returns the top n ngrams when scored by the given function.
score_ngram(score_fn, w1, w2, w3) Returns the score for a given trigram using the given scoring function.
score_ngrams(score_fn) Returns a sequence of (ngram, score) pairs ordered from highest to lowest score, as determined by the scoring function provided.