class documentation

class QuadgramAssocMeasures(NgramAssocMeasures): (source)

View In Hierarchy

A collection of quadgram association measures. Each association measure is provided as a function with five arguments:

trigram_score_fn(n_iiii,
                (n_iiix, n_iixi, n_ixii, n_xiii),
                (n_iixx, n_ixix, n_ixxi, n_xixi, n_xxii, n_xiix),
                (n_ixxx, n_xixx, n_xxix, n_xxxi),
                n_all)

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_iiii counts (w1, w2, w3, w4), i.e. the quadgram being scored n_ixxi counts (w1, , *, w4) n_xxxx counts (, *, *, *), i.e. any quadgram

Static Method _contingency Calculates values of a quadgram contingency table from marginal values.
Static Method _marginals Calculates values of contingency table marginals from its values. QuadgramAssocMeasures._marginals(1, 0, 2, 46, 552, 825, 2577, 34967, 1, 0, 2, 48, 7250, 9031, 28585, 356653) (1, (2, 553, 3, 1), (7804, 6, 3132, 1378, 49, 2), (38970, 17660, 100, 38970), 440540)...
Class Variable _n Undocumented

Inherited from NgramAssocMeasures:

Class Method chi_sq 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_ratio 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_stirling Scores ngrams using the Poisson-Stirling measure.
Class Method student_t Scores ngrams using Student's t test with independence hypothesis for unigrams, as in Manning and Schutze 5.3.1.
Static Method mi_like 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_freq Scores ngrams by their frequency
Class Method _expected_values Calculates expected values for a contingency table.
@staticmethod
def _contingency(n_iiii, n_iiix_tuple, n_iixx_tuple, n_ixxx_tuple, n_xxxx): (source)

Calculates values of a quadgram contingency table from marginal values.

@staticmethod
def _marginals(*contingency): (source)

Calculates values of contingency table marginals from its values. QuadgramAssocMeasures._marginals(1, 0, 2, 46, 552, 825, 2577, 34967, 1, 0, 2, 48, 7250, 9031, 28585, 356653) (1, (2, 553, 3, 1), (7804, 6, 3132, 1378, 49, 2), (38970, 17660, 100, 38970), 440540)