§
    'ê[f¹@  ã                   ó  — d Z ddlZddlmZmZ ddlmZ d„ Zej	        Z
d„ ZdZ	 ddlmZ n# e$ r d	„ ZY nw xY wdZ	 d
Z	 dZ	  G d„ de¬¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ d¦  «        ZdS )zÌ
Provides scoring functions for a number of association measures through a
generic, abstract implementation in ``NgramAssocMeasures``, and n-specific
``BigramAssocMeasures`` and ``TrigramAssocMeasures``.
é    N)ÚABCMetaÚabstractmethod©Úreducec                 ó*   — t          j        | ¦  «        S ©N)Ú_mathÚlog2)Úxs    úL/var/www/piapp/venv/lib/python3.11/site-packages/nltk/metrics/association.pyú<lambda>r      s   € •%”*˜Q‘-”-€ ó    c                 ó$   — t          d„ | ¦  «        S )Nc                 ó   — | |z  S r   © )r   Úys     r   r   z<lambda>.<locals>.<lambda>   s
   € ¨¨Q©€ r   r   )Úss    r   r   r      s   € •VÐ.Ð.°Ñ2Ô2€ r   g#B’¡œÇ;)Úfisher_exactc                  ó   — t           ‚r   ©ÚNotImplementedError)Ú_argsÚ_kwargss     r   r   r      s   € Ý!Ð!r   éþÿÿÿéÿÿÿÿc                   ó(  — e Zd ZdZdZeed„ ¦   «         ¦   «         Zeed„ ¦   «         ¦   «         Ze	d„ ¦   «         Z
ed„ ¦   «         Ze	d„ ¦   «         Ze	d„ ¦   «         Zed	„ ¦   «         Ze	d
„ ¦   «         Ze	d„ ¦   «         Ze	d„ ¦   «         Ze	d„ ¦   «         ZdS )ÚNgramAssocMeasuresa¿  
    An abstract class defining a collection of generic association measures.
    Each public method returns a score, taking the following arguments::

        score_fn(count_of_ngram,
                 (count_of_n-1gram_1, ..., count_of_n-1gram_j),
                 (count_of_n-2gram_1, ..., count_of_n-2gram_k),
                 ...,
                 (count_of_1gram_1, ..., count_of_1gram_n),
                 count_of_total_words)

    See ``BigramAssocMeasures`` and ``TrigramAssocMeasures``

    Inheriting classes should define a property _n, and a method _contingency
    which calculates contingency values from marginals in order for all
    association measures defined here to be usable.
    r   c                  ó    — t          d¦  «        ‚)z>Calculates values of a contingency table from marginal values.ú?The contingency table is not availablein the general ngram caser   ©Ú	marginalss    r   Ú_contingencyzNgramAssocMeasures._contingencyB   ó   € õ "ØPñ
ô 
ð 	
r   c                  ó    — t          d¦  «        ‚)úACalculates values of contingency table marginals from its values.r   r   )Úcontingencys    r   Ú
_marginalszNgramAssocMeasures._marginalsJ   r#   r   c              #   ó  ‡ ‡‡K  — t          ‰¦  «        }d„ t          ‰ j        ¦  «        D ¦   «         }t          t          ‰¦  «        ¦  «        D ]/Št	          ˆ ˆˆfd„|D ¦   «         ¦  «        |‰ j        dz
  z  z  V — Œ0dS )ú3Calculates expected values for a contingency table.c                 ó   — g | ]}d |z  ‘ŒS )é   r   )Ú.0Úis     r   ú
<listcomp>z7NgramAssocMeasures._expected_values.<locals>.<listcomp>V   s   € Ð.Ð.Ð.˜1��Q‘Ð.Ð.Ð.r   c              3   ó~   •‡K  — | ]6Št          ˆˆˆfd „t          d‰j        z  ¦  «        D ¦   «         ¦  «        V — Œ7dS )c              3   ó@   •K  — | ]}|‰z  ‰‰z  k    ¯‰|         V — Œd S r   r   )r,   r   Úcontr-   Újs     €€€r   ú	<genexpr>z@NgramAssocMeasures._expected_values.<locals>.<genexpr>.<genexpr>]   s9   øè è € ÐPÐP A¸aÀ!¹eÈÈQÉÒ=OÐ=O˜˜QœÐ=OÐ=OÐ=OÐ=OÐPÐPr   é   N)ÚsumÚrangeÚ_n)r,   r2   Úclsr1   r-   s    @€€€r   r3   z6NgramAssocMeasures._expected_values.<locals>.<genexpr>\   si   øøè è € ð ð àõ ÐPÐPÐPÐPÐPÐP­¨q°#´&©yÑ)9Ô)9ÐPÑPÔPÑPÔPðð ð ð ð ð r   r+   N)r5   r6   r7   ÚlenÚ_product)r8   r1   Ún_allÚbitsr-   s   ``  @r   Ú_expected_valuesz#NgramAssocMeasures._expected_valuesR   sÂ   øøøè è € õ �D‘	”	ˆØ.Ð.¥ c¤f¡¤Ð.Ñ.Ô.ˆõ •s˜4‘y”yÑ!Ô!ð 	ð 	ˆAõ ð ð ð ð ð ð à!ðñ ô ñ ô ð ˜SœV a™ZÑ(ñ	*ðð ð ð ð	ð 	r   c                  ó8   — | t                    | t                   z  S )z Scores ngrams by their frequency)ÚNGRAMÚTOTALr    s    r   Úraw_freqzNgramAssocMeasures.raw_freqc   s   € ð �Ô )­EÔ"2Ñ2Ð2r   c                 ó¶   — |t                    t          |t                   ¦  «        |t                   | j        dz
  z  z  z
  |t                    t
          z   dz  z  S )z�Scores ngrams using Student's t test with independence hypothesis
        for unigrams, as in Manning and Schutze 5.3.1.
        r+   g      à?)r?   r:   ÚUNIGRAMSr@   r7   Ú_SMALL©r8   r!   s     r   Ú	student_tzNgramAssocMeasures.student_th   sS   € ð •eÔÝ�y¥Ô*Ñ+Ô+¨y½Ô/?ÀCÄFÈQÁJÑ/OÑPñQà•uÔ¥Ñ&¨3Ñ.ñ/ð 	/r   c                 óŽ   —  | j         |Ž }|                      |¦  «        }t          d„ t          ||¦  «        D ¦   «         ¦  «        S )zZScores ngrams using Pearson's chi-square as in Manning and Schutze
        5.3.3.
        c              3   óB   K  — | ]\  }}||z
  d z  |t           z   z  V — ŒdS )r4   N)rD   ©r,   ÚobsÚexps      r   r3   z,NgramAssocMeasures.chi_sq.<locals>.<genexpr>y   s8   è è € ÐUÐU¹¸¸c�C˜#‘I !Ñ# s­V¡|Ñ4ÐUÐUÐUÐUÐUÐUr   )r"   r=   r5   Úzip)r8   r!   r1   Úexpss       r   Úchi_sqzNgramAssocMeasures.chi_sqr   sK   € ð
  ˆsÔ Ð+ˆØ×#Ò# DÑ)Ô)ˆÝÐUÐUÅSÈÈtÁ_Ä_ÐUÑUÔUÑUÔUÐUr   c                  ó€   — | t                    |                     dd¦  «        z  t          | t                   ¦  «        z  S )zÂ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.
        Úpoweré   )r?   Úgetr:   rC   )r!   Úkwargss     r   Úmi_likezNgramAssocMeasures.mi_like{   s=   € ð �Ô 6§:¢:¨g°qÑ#9Ô#9Ñ9½HØ•hÔñ=
ô =
ñ 
ð 	
r   c                 ó¸   — t          |t                   |t                   | j        dz
  z  z  ¦  «        t          t	          |t
                   ¦  «        ¦  «        z
  S )z^Scores ngrams by pointwise mutual information, as in Manning and
        Schutze 5.4.
        r+   )Ú_log2r?   r@   r7   r:   rC   rE   s     r   ÚpmizNgramAssocMeasures.pmi…   sQ   € õ
 �Y�uÔ%¨	µ%Ô(8¸S¼VÀa¹ZÑ(HÑHÑIÔIÍEÝ�Y�xÔ(Ñ)Ô)ñM
ô M
ñ 
ð 	
r   c           
      ó�   —  | j         |Ž }dt          d„ t          ||                      |¦  «        ¦  «        D ¦   «         ¦  «        z  S )zFScores ngrams using likelihood ratios as in Manning and Schutze 5.3.4.r4   c              3   óf   K  — | ],\  }}|t          ||t          z   z  t          z   ¦  «        z  V — Œ-d S r   )Ú_lnrD   rI   s      r   r3   z6NgramAssocMeasures.likelihood_ratio.<locals>.<genexpr>’   sU   è è € ð 
ð 
á��Sð •#�c˜S¥6™\Ñ*­VÑ3Ñ4Ô4Ñ4ð
ð 
ð 
ð 
ð 
ð 
r   )r"   r5   rL   r=   ©r8   r!   r1   s      r   Úlikelihood_ratioz#NgramAssocMeasures.likelihood_ratioŽ   s`   € ð  ˆsÔ Ð+ˆØ•3ð 
ð 
å  c×&:Ò&:¸4Ñ&@Ô&@ÑAÔAð
ñ 
ô 
ñ 
ô 
ñ 
ð 	
r   c                 óÄ   — t          |t                   ¦  «        |t                   | j        dz
  z  z  }|t                   t          |t                   |z  ¦  «        dz
  z  S )z1Scores ngrams using the Poisson-Stirling measure.r+   )r:   rC   r@   r7   r?   rV   )r8   r!   rK   s      r   Úpoisson_stirlingz#NgramAssocMeasures.poisson_stirling—   sR   € õ �y¥Ô*Ñ+Ô+¨y½Ô/?ÀCÄFÈQÁJÑ/OÑPˆØ�Ô¥5¨µ5Ô)9¸CÑ)?Ñ#@Ô#@À1Ñ#DÑEÐEr   c                 óV   —  | j         |Ž }|d         t          |dd…         ¦  «        z  S )z&Scores ngrams using the Jaccard index.r   Nr   )r"   r5   r[   s      r   ÚjaccardzNgramAssocMeasures.jaccard�   s0   € ð  ˆsÔ Ð+ˆØ�AŒw�˜T # 2 #œY™œÑ'Ð'r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r7   Ústaticmethodr   r"   r'   Úclassmethodr=   rA   rF   rN   rT   rW   r\   r^   r`   r   r   r   r   r   -   sf  € € € € € ðð ð$ 
€BàØð
ð 
ñ „^ñ „\ð
ð Øð
ð 
ñ „^ñ „\ð
ð ðð ñ „[ðð  ð3ð 3ñ „\ð3ð ð/ð /ñ „[ð/ð ðVð Vñ „[ðVð ð
ð 
ñ „\ð
ð ð
ð 
ñ „[ð
ð ð
ð 
ñ „[ð
ð ðFð Fñ „[ðFð
 ð(ð (ñ „[ð(ð (ð (r   r   )Ú	metaclassc                   ó°   — e Zd ZdZdZed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Ze	d„ ¦   «         Z
e	d„ ¦   «         Ze	d„ ¦   «         Zed	„ ¦   «         Zd
S )ÚBigramAssocMeasuresaˆ  
    A collection of bigram association measures. Each association measure
    is provided as a function with three arguments::

        bigram_score_fn(n_ii, (n_ix, n_xi), n_xx)

    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_ii counts ``(w1, w2)``, i.e. the bigram being scored
    - n_ix counts ``(w1, *)``
    - n_xi counts ``(*, w2)``
    - n_xx counts ``(*, *)``, i.e. any bigram

    This may be shown with respect to a contingency table::

                w1    ~w1
             ------ ------
         w2 | n_ii | n_oi | = n_xi
             ------ ------
        ~w2 | n_io | n_oo |
             ------ ------
             = n_ix        TOTAL = n_xx
    r4   c                 ó>   — |\  }}|| z
  }|| z
  }| |||| z
  |z
  |z
  fS )zECalculates values of a bigram contingency table from marginal values.r   )Ún_iiÚn_ix_xi_tupleÚn_xxÚn_ixÚn_xiÚn_oiÚn_ios          r   r"   z BigramAssocMeasures._contingencyÂ   s<   € ð %‰ˆˆtØ�d‰{ˆØ�d‰{ˆØ�d˜D $¨¡+°Ñ"4°tÑ";Ð<Ð<r   c                 ó.   — | || z   || z   f||z   |z   | z   fS )r%   r   )rk   rp   rq   Ún_oos       r   r'   zBigramAssocMeasures._marginalsÊ   s,   € ð �t˜d‘{ D¨4¡KÐ0°$¸±+ÀÑ2DÀtÑ2KÐLÐLr   c              #   ó¨   K  — t          | ¦  «        }t          d¦  «        D ]0}| |         | |dz           z   | |         | |dz           z   z  |z  V — Œ1dS )r)   é   r+   r4   N)r5   r6   )r1   rm   r-   s      r   r=   z$BigramAssocMeasures._expected_valuesÏ   sq   è è € õ �4‰yŒyˆå�q‘”ð 	Kð 	KˆAØ˜”7˜T ! a¡%œ[Ñ(¨T°!¬W°t¸AÀ¹E´{Ñ-BÑCÀdÑJÐJÐJÐJÐJð	Kð 	Kr   c                 ól   —  | j         |Ž \  }}}}||z  ||z  z
  dz  ||z   ||z   z  ||z   z  ||z   z  z  S )zdScores bigrams using phi-square, the square of the Pearson correlation
        coefficient.
        r4   )r"   )r8   r!   rk   rq   rp   rs   s         r   Úphi_sqzBigramAssocMeasures.phi_sq×   s]   € ð
 "2 Ô!1°9Ð!=Ñˆˆd�D˜$à�t‘˜d T™kÑ)¨aÑ/Ø�D‰[˜T D™[Ñ)¨T°D©[Ñ9¸TÀD¹[ÑIñ
ð 	
r   c                 óD   — |\  }}||                       |||f|¦  «        z  S )zƒScores bigrams using chi-square, i.e. phi-sq multiplied by the number
        of bigrams, as in Manning and Schutze 5.3.3.
        )rw   )r8   rk   rl   rm   rn   ro   s         r   rN   zBigramAssocMeasures.chi_sqâ   s,   € ð
 %‰ˆˆtØ�c—j’j ¨¨d |°TÑ:Ô:Ñ:Ð:r   c                 óX   —  | j         |Ž \  }}}}t          ||g||ggd¬¦  «        \  }}|S )zºScores bigrams using Fisher's Exact Test (Pedersen 1996).  Less
        sensitive to small counts than PMI or Chi Sq, but also more expensive
        to compute. Requires scipy.
        Úless)Úalternative)r"   r   )r8   r!   rk   rq   rp   rs   ÚoddsÚpvalues           r   ÚfisherzBigramAssocMeasures.fisherê   sE   € ð "2 Ô!1°9Ð!=Ñˆˆd�D˜$å%¨¨d |°d¸D°\Ð&BÐPVÐWÑWÔW‰ˆˆvØˆr   c                 ó"   — |\  }}d| z  ||z   z  S )z(Scores bigrams using Dice's coefficient.r4   r   )rk   rl   rm   rn   ro   s        r   ÚdicezBigramAssocMeasures.diceö   s    € ð %‰ˆˆtØ�4‰x˜4 $™;Ñ'Ð'r   N)ra   rb   rc   rd   r7   re   r"   r'   r=   rf   rw   rN   r~   r€   r   r   r   ri   ri   ¤   sæ   € € € € € ðð ð6 
€Bàð=ð =ñ „\ð=ð ðMð Mñ „\ðMð ðKð Kñ „\ðKð ð
ð 
ñ „[ð
ð ð;ð ;ñ „[ð;ð ð	ð 	ñ „[ð	ð ð(ð (ñ „\ð(ð (ð (r   ri   c                   óB   — e Zd ZdZdZed„ ¦   «         Zed„ ¦   «         ZdS )ÚTrigramAssocMeasuresa×  
    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
    rQ   c                 ó¼   — |\  }}}|\  }}}	|| z
  }
|| z
  }|| z
  }|	| z
  |
z
  |z
  }|| z
  |
z
  |z
  }|| z
  |z
  |z
  }|| z
  |
z
  |z
  |z
  |z
  |z
  |z
  }| |
||||||fS )zÔ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)
        r   )Ún_iiiÚn_iix_tupleÚn_ixx_tupleÚn_xxxÚn_iixÚn_ixiÚn_xiiÚn_ixxÚn_xixÚn_xxiÚn_oiiÚn_ioiÚn_iioÚn_ooiÚn_oioÚn_iooÚn_ooos                    r   r"   z!TrigramAssocMeasures._contingency  s®   € ð !,Ñˆ��uØ +Ñˆ��uØ˜‘ˆØ˜‘ˆØ˜‘ˆØ˜‘ Ñ%¨Ñ-ˆØ˜‘ Ñ%¨Ñ-ˆØ˜‘ Ñ%¨Ñ-ˆØ˜‘ Ñ%¨Ñ-°Ñ5¸Ñ=ÀÑEÈÑMˆà�u˜e U¨E°5¸%ÀÐGÐGr   c                  ó’   — | \  }}}}}}}}|||z   ||z   ||z   f||z   |z   |z   ||z   |z   |z   ||z   |z   |z   ft          | ¦  «        fS )z»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)
        ©r5   )	r&   r„   rŽ   r�   r‘   r�   r’   r“   r”   s	            r   r'   zTrigramAssocMeasures._marginals&  s„   € ð BMÑ>ˆˆu�e˜U E¨5°%¸àØ�U‰]˜E E™M¨5°5©=Ð9à˜‘ Ñ%¨Ñ-Ø˜‘ Ñ%¨Ñ-Ø˜‘ Ñ%¨Ñ-ðõ
 �ÑÔð	
ð 		
r   N©ra   rb   rc   rd   r7   re   r"   r'   r   r   r   r‚   r‚   ý   s\   € € € € € ðð ð& 
€BàðHð Hñ „\ðHð$ ð
ð 
ñ „\ð
ð 
ð 
r   r‚   c                   óB   — e Zd ZdZdZed„ ¦   «         Zed„ ¦   «         ZdS )ÚQuadgramAssocMeasuresaF  
    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
    ru   c                 ó  — |\  }}}}|\  }	}
}}}}|\  }}}}|| z
  }|| z
  }|| z
  }|| z
  |z
  |z
  }|| z
  |z
  |z
  }|| z
  |z
  |z
  }|| z
  |z
  |z
  |z
  |z
  |z
  |z
  }|| z
  }|| z
  |z
  |z
  }|
| z
  |z
  |z
  }|| z
  |z
  |z
  |z
  |z
  |z
  |z
  }|	| z
  |z
  |z
  }|| z
  |z
  |z
  |z
  |z
  |z
  |z
  }|| z
  |z
  |z
  |z
  |z
  |z
  |z
  } || z
  |z
  |z
  |z
  |z
  |z
  |z
  |z
  |z
  |z
  |z
  |z
  |z
  |z
  | z
  }!| |||||||||||||| |!fS )zXCalculates values of a quadgram contingency table from
        marginal values.
        r   )"Ún_iiiiÚn_iiix_tupleÚn_iixx_tupleÚn_ixxx_tupleÚn_xxxxÚ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_oiiiÚn_ioiiÚn_iioiÚn_ooiiÚn_oioiÚn_iooiÚn_oooiÚn_iiioÚn_oiioÚn_ioioÚn_ooioÚn_iiooÚn_oiooÚn_ioooÚn_oooos"                                     r   r"   z"QuadgramAssocMeasures._contingencyP  s>  € ð
 ,8Ñ(ˆ�˜ Ø;GÑ8ˆ�˜ ¨°Ø+7Ñ(ˆ�˜ Ø˜&‘ˆØ˜&‘ˆØ˜&‘ˆØ˜&‘ 6Ñ)¨FÑ2ˆØ˜&‘ 6Ñ)¨FÑ2ˆØ˜&‘ 6Ñ)¨FÑ2ˆØ˜&‘ 6Ñ)¨FÑ2°VÑ;¸fÑDÀvÑMÐPVÑVˆØ˜&‘ˆØ˜&‘ 6Ñ)¨FÑ2ˆØ˜&‘ 6Ñ)¨FÑ2ˆØ˜&‘ 6Ñ)¨FÑ2°VÑ;¸fÑDÀvÑMÐPVÑVˆØ˜&‘ 6Ñ)¨FÑ2ˆØ˜&‘ 6Ñ)¨FÑ2°VÑ;¸fÑDÀvÑMÐPVÑVˆØ˜&‘ 6Ñ)¨FÑ2°VÑ;¸fÑDÀvÑMÐPVÑVˆàØñàñð ñð ñ	ð
 ñð ñð ñð ñð ñ	ð ñ
ð ñð ñð ñð ñð ñð 	ð( ØØØØØØØØØØØØØØØð!
ð 	
r   c                  óÔ  — | \  }}}}}}}}}	}
}}}}}}||	z   }||z   }||z   }||z   }||z   |	z   |z   }||z   |	z   |z   }||z   |z   |z   }||z   |z   |z   }||z   |z   |z   }||z   |	z   |
z   }||z   |z   |	z   |z   |z   |z   |z   }||z   |z   |	z   |z   |
z   |z   |z   }||z   |z   |	z   |z   |z   |
z   |z   }||z   |z   |z   |z   |z   |z   |z   }t          | ¦  «        }|||||f||||||f||||f|fS )a  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)
        r–   ) r&   r›   r®   r¯   r±   r°   r²   r³   r´   rµ   r¶   r·   r¸   r¹   rº   r»   r¼   r    r¡   r¢   r£   r¤   r¥   r¦   r§   r¨   r©   rª   r«   r¬   r­   r;   s                                    r   r'   z QuadgramAssocMeasures._marginalsŒ  s»  € ð. ñ#	
ØØØØØØØØØØØØØØØØð ˜&‘ˆØ˜&‘ˆØ˜&‘ˆØ˜&‘ˆà˜&‘ 6Ñ)¨FÑ2ˆØ˜&‘ 6Ñ)¨FÑ2ˆØ˜&‘ 6Ñ)¨FÑ2ˆØ˜&‘ 6Ñ)¨FÑ2ˆØ˜&‘ 6Ñ)¨FÑ2ˆØ˜&‘ 6Ñ)¨FÑ2ˆà˜&‘ 6Ñ)¨FÑ2°VÑ;¸fÑDÀvÑMÐPVÑVˆØ˜&‘ 6Ñ)¨FÑ2°VÑ;¸fÑDÀvÑMÐPVÑVˆØ˜&‘ 6Ñ)¨FÑ2°VÑ;¸fÑDÀvÑMÐPVÑVˆØ˜&‘ 6Ñ)¨FÑ2°VÑ;¸fÑDÀvÑMÐPVÑVˆå�KÑ Ô ˆð Ø�V˜V VÐ,Ø�V˜V V¨V°VÐ<Ø�V˜V VÐ,Øð
ð 	
r   Nr—   r   r   r   r™   r™   9  sZ   € € € € € ðð ð( 
€Bàð9
ð 9
ñ „\ð9
ðv ð1
ð 1
ñ „\ð1
ð 1
ð 1
r   r™   c                   ó.   — e Zd ZdZd„ Zed„ ¦   «         ZdS )ÚContingencyMeasuresz�Wraps NgramAssocMeasures classes such that the arguments of association
    measures are contingency table values rather than marginals.
    c                 ó   — d|j         j        z   | j         _        t          |¦  «        D ]d}|                     d¦  «        rŒt	          ||¦  «        }|                     d¦  «        s|                      ||¦  «        }t          | ||¦  «         ŒedS )zAConstructs a ContingencyMeasures given a NgramAssocMeasures classÚContingencyÚ__Ú_N)Ú	__class__ra   ÚdirÚ
startswithÚgetattrÚ_make_contingency_fnÚsetattr)ÚselfÚmeasuresÚkÚvs       r   Ú__init__zContingencyMeasures.__init__Æ  sš   € à"/°(Ô2DÔ2MÑ"MˆŒÔÝ�X‘”ð 	 ð 	 ˆAØ�|Š|˜DÑ!Ô!ð ØÝ˜ !Ñ$Ô$ˆAØ—<’< Ñ$Ô$ð ;Ø×-Ò-¨h¸Ñ:Ô:�Ý�D˜!˜QÑÔÐÐð	 ð 	 r   c                 óF   ‡ ‡— ˆ ˆfd„}‰j         |_         ‰j        |_        |S )z‡From an association measure function, produces a new function which
        accepts contingency table values as its arguments.
        c                  ó   •—  ‰ ‰j         | Ž Ž S r   )r'   )r&   rË   Úold_fns    €€r   Úresz5ContingencyMeasures._make_contingency_fn.<locals>.res×  s   ø€ Ø�6Ð.˜8Ô.°Ð<Ð=Ð=r   )rd   ra   )rË   rÑ   rÒ   s   `` r   rÈ   z(ContingencyMeasures._make_contingency_fnÑ  s;   øø€ ð	>ð 	>ð 	>ð 	>ð 	>ð 	>ð ”nˆŒØ”ˆŒØˆ
r   N)ra   rb   rc   rd   rÎ   re   rÈ   r   r   r   r¿   r¿   Á  sH   € € € € € ðð ð	 ð 	 ð 	 ð ð
ð 
ñ „\ð
ð 
ð 
r   r¿   )rd   Úmathr	   Úabcr   r   Ú	functoolsr   rV   ÚlogrZ   r:   rD   Úscipy.statsr   ÚImportErrorr?   rC   r@   r   ri   r‚   r™   r¿   r   r   r   ú<module>rÙ      sÊ  ððð ð Ð Ð Ð Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø Ð Ð Ð Ð Ð àÐ€Ø„i€à2Ð2€à	€ð"Ø(Ð(Ð(Ð(Ð(Ð(Ð(øØð "ð "ð "ð"ð "ð "ð "ð "ð"øøøð 	
€Ø )à€Ø 7à
€Ø 9ðt(ð t(ð t(ð t(ð t( 7ð t(ñ t(ô t(ð t(ðnV(ð V(ð V(ð V(ð V(Ð,ñ V(ô V(ð V(ðr9
ð 9
ð 9
ð 9
ð 9
Ð-ñ 9
ô 9
ð 9
ðxE
ð E
ð E
ð E
ð E
Ð.ñ E
ô E
ð E
ðPð ð ð ð ñ ô ð ð ð s   ¥, ¬7¶7