nltk.collocations.TrigramCollocationFinder¶
- class nltk.collocations.TrigramCollocationFinder[source]¶
Bases:
AbstractCollocationFinder
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.
- default_ws = 3¶
- __init__(word_fd, bigram_fd, wildcard_fd, trigram_fd)[source]¶
Construct a TrigramCollocationFinder, given FreqDists for appearances of words, bigrams, two words with any word between them, and trigrams.
- classmethod from_words(words, window_size=3)[source]¶
Construct a TrigramCollocationFinder for all trigrams in the given sequence.
- bigram_finder()[source]¶
Constructs a bigram collocation finder with the bigram and unigram data from this finder. Note that this does not include any filtering applied to this finder.
- score_ngram(score_fn, w1, w2, w3)[source]¶
Returns the score for a given trigram using the given scoring function.
- above_score(score_fn, min_score)[source]¶
Returns a sequence of ngrams, ordered by decreasing score, whose scores each exceed the given minimum score.
- apply_freq_filter(min_freq)[source]¶
Removes candidate ngrams which have frequency less than min_freq.
- apply_ngram_filter(fn)[source]¶
Removes candidate ngrams (w1, w2, …) where fn(w1, w2, …) evaluates to True.
- apply_word_filter(fn)[source]¶
Removes candidate ngrams (w1, w2, …) where any of (fn(w1), fn(w2), …) evaluates to True.