class TrigramAssocMeasures(NgramAssocMeasures): (source)
A collection of trigram association measures. Each association measure is provided as a function with four arguments:
trigram_score_fn(n_iii, (n_iix, n_ixi, n_xii), (n_ixx, n_xix, n_xxi), n_xxx)
The arguments constitute the marginals of a contingency table, counting the occurrences of particular events in a corpus. The letter i in the suffix refers to the appearance of the word in question, while x indicates the appearance of any word. Thus, for example: n_iii counts (w1, w2, w3), i.e. the trigram being scored n_ixx counts (w1, , *) n_xxx counts (, *, *), i.e. any trigram
Static Method | _contingency |
Calculates values of a trigram contingency table (or cube) from marginal values. >>> TrigramAssocMeasures._contingency(1, (1, 1, 1), (1, 73, 1), 2000) (1, 0, 0, 0, 0, 72, 0, 1927) |
Static Method | _marginals |
Calculates values of contingency table marginals from its values. >>> TrigramAssocMeasures._marginals(1, 0, 0, 0, 0, 72, 0, 1927) (1, (1, 1, 1), (1, 73, 1), 2000) |
Class Variable | _n |
Undocumented |
Inherited from NgramAssocMeasures
:
Class Method | chi |
Scores ngrams using Pearson's chi-square as in Manning and Schutze 5.3.3. |
Class Method | jaccard |
Scores ngrams using the Jaccard index. |
Class Method | likelihood |
Scores ngrams using likelihood ratios as in Manning and Schutze 5.3.4. |
Class Method | pmi |
Scores ngrams by pointwise mutual information, as in Manning and Schutze 5.4. |
Class Method | poisson |
Scores ngrams using the Poisson-Stirling measure. |
Class Method | student |
Scores ngrams using Student's t test with independence hypothesis for unigrams, as in Manning and Schutze 5.3.1. |
Static Method | mi |
Scores ngrams using a variant of mutual information. The keyword argument power sets an exponent (default 3) for the numerator. No logarithm of the result is calculated. |
Static Method | raw |
Scores ngrams by their frequency |
Class Method | _expected |
Calculates expected values for a contingency table. |
Calculates values of a trigram contingency table (or cube) from marginal values. >>> TrigramAssocMeasures._contingency(1, (1, 1, 1), (1, 73, 1), 2000) (1, 0, 0, 0, 0, 72, 0, 1927)