§
    'ê[fþ  ã                   óx   — d dl Z d dlmZ d dlmZ d dlmZ  G d„ de¦  «        Zd„ Ze	dk    r e¦   «          dS dS )	é    N)Údefaultdict)Úreduce)ÚCorpusReaderc                   óx   ‡ — e Zd ZdZ ej        d¦  «        Zed„ ¦   «         Zdˆ fd„	Z	dd„Z
dd„Zdd	„Zd
„ Zˆ xZS )ÚLinThesaurusCorpusReaderzEWrapper for the LISP-formatted thesauruses distributed by Dekang Lin.z \("?([^"]+)"? \(desc [0-9.]+\).+c                  ó*   — t          t          ¦  «        S )z6Factory for creating defaultdict of defaultdict(dict)s)r   Údict© ó    úJ/var/www/piapp/venv/lib/python3.11/site-packages/nltk/corpus/reader/lin.pyÚ__defaultdict_factoryz.LinThesaurusCorpusReader.__defaultdict_factory   s   € õ �4Ñ Ô Ð r   ç        c                 óz  •— t          ¦   «                              |d¦  «         t          t          j        ¦  «        | _        || _        |                      dd¬¦  «        D ]Ú\  }}}t          |¦  «        5 }d}|D ]§}| 	                    ¦   «         }|r#t          j
                             d|¦  «        }	d}Œ;|dk    rd}ŒD|                     d¦  «        }
t          |
¦  «        dk    r;|
\  }}t          |¦  «        | j        |         |	         | 	                    d	¦  «        <   Œ¨	 d
d
d
¦  «         n# 1 swxY w Y   ŒÛd
S )a  
        Initialize the thesaurus.

        :param root: root directory containing thesaurus LISP files
        :type root: C{string}
        :param badscore: the score to give to words which do not appear in each other's sets of synonyms
        :type badscore: C{float}
        zsim[A-Z]\.lspT)Úinclude_encodingÚinclude_fileidz\1Fz))ú	é   ú"N)ÚsuperÚ__init__r   r   Ú._LinThesaurusCorpusReader__defaultdict_factoryÚ
_thesaurusÚ	_badscoreÚabspathsÚopenÚstripÚ_key_reÚsubÚsplitÚlenÚfloat)ÚselfÚrootÚbadscoreÚpathÚencodingÚfileidÚlin_fileÚfirstÚlineÚkeyÚ
split_lineÚngramÚscoreÚ	__class__s                €r   r   z!LinThesaurusCorpusReader.__init__   s�  ø€ õ 	‰Œ×Ò˜Ð/Ñ0Ô0Ð0Ý%Õ&>Ô&TÑUÔUˆŒØ!ˆŒØ&*§m¢mØ!°$ð '4ñ '
ô '
ð 	ð 	Ñ"ˆD�(˜Fõ �d‘”ð ˜xØ�Ø$ð ð �DØŸ:š:™<œ<�Dàð Ý6Ô>×BÒBÀ5È$ÑOÔO˜Ø %˜˜à š˜Ø $˜˜ð &*§Z¢Z°Ñ%5Ô%5˜
Ý˜z™?œ?¨aÒ/Ð/Ø+5™L˜E 5ÝMRØ %ñNô N˜DœO¨FÔ3°CÔ8¸¿ºÀSÑ9IÔ9IÑJøððð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð øð	ð 	s   Á5B-D/Ä/D3	Ä6D3	Nc                 óÖ   ‡ ‡‡— ‰‰k    r|rdS d„ ‰ j         D ¦   «         S |r5‰‰ j        |         ‰         v r‰ j        |         ‰         ‰         n‰ j        S ˆˆˆ fd„‰ j         D ¦   «         S )aÝ  
        Returns the similarity score for two ngrams.

        :param ngram1: first ngram to compare
        :type ngram1: C{string}
        :param ngram2: second ngram to compare
        :type ngram2: C{string}
        :param fileid: thesaurus fileid to search in. If None, search all fileids.
        :type fileid: C{string}
        :return: If fileid is specified, just the score for the two ngrams; otherwise,
                 list of tuples of fileids and scores.
        ç      ð?c                 ó   — g | ]}|d f‘ŒS )r1   r
   )Ú.0Úfids     r   ú
<listcomp>z7LinThesaurusCorpusReader.similarity.<locals>.<listcomp>Q   s   € Ð<Ð<Ð< s˜˜c˜
Ð<Ð<Ð<r   c                 ó~   •— g | ]9}|‰‰j         |         ‰         v r‰j         |         ‰         ‰         n‰j        f‘Œ:S r
   )r   r   )r3   r4   Úngram1Úngram2r"   s     €€€r   r5   z7LinThesaurusCorpusReader.similarity.<locals>.<listcomp>Z   sg   ø€ ð 
ð 
ð 
ð ð ð  &¨¬¸Ô)=¸fÔ)EÐEÐEð !œO¨CÔ0°Ô8¸Ô@Ð@à!%¤ðð
ð 
ð 
r   )Ú_fileidsr   r   )r"   r7   r8   r'   s   ``` r   Ú
similarityz#LinThesaurusCorpusReader.similarity?   s²   øøø€ ð �VÒÐØð =Ø�sà<Ð<¨d¬mÐ<Ñ<Ô<Ð<àð ð  ¤°Ô!8¸Ô!@Ð@Ð@ð ”O FÔ+¨FÔ3°FÔ;Ð;àœðð
ð 
ð 
ð 
ð 
ð 
ð  $œ}ð
ñ 
ô 
ð 
r   c                 ó|   ‡ ‡— |r%‰ j         |         ‰                              ¦   «         S ˆˆ fd„‰ j        D ¦   «         S )a   
        Returns a list of scored synonyms (tuples of synonyms and scores) for the current ngram

        :param ngram: ngram to lookup
        :type ngram: C{string}
        :param fileid: thesaurus fileid to search in. If None, search all fileids.
        :type fileid: C{string}
        :return: If fileid is specified, list of tuples of scores and synonyms; otherwise,
                 list of tuples of fileids and lists, where inner lists consist of tuples of
                 scores and synonyms.
        c                 ó^   •— g | ])}|‰j         |         ‰                              ¦   «         f‘Œ*S r
   )r   Úitems©r3   r'   r-   r"   s     €€r   r5   z<LinThesaurusCorpusReader.scored_synonyms.<locals>.<listcomp>u   sF   ø€ ð ð ð àð ˜œ¨Ô0°Ô7×=Ò=Ñ?Ô?Ð@ðð ð r   )r   r=   r9   ©r"   r-   r'   s   `` r   Úscored_synonymsz(LinThesaurusCorpusReader.scored_synonymsf   s^   øø€ ð ð 	Ø”? 6Ô*¨5Ô1×7Ò7Ñ9Ô9Ð9ðð ð ð ð à"œmðñ ô ð r   c                 ó|   ‡ ‡— |r%‰ j         |         ‰                              ¦   «         S ˆˆ fd„‰ j        D ¦   «         S )aœ  
        Returns a list of synonyms for the current ngram.

        :param ngram: ngram to lookup
        :type ngram: C{string}
        :param fileid: thesaurus fileid to search in. If None, search all fileids.
        :type fileid: C{string}
        :return: If fileid is specified, list of synonyms; otherwise, list of tuples of fileids and
                 lists, where inner lists contain synonyms.
        c                 ó^   •— g | ])}|‰j         |         ‰                              ¦   «         f‘Œ*S r
   )r   Úkeysr>   s     €€r   r5   z5LinThesaurusCorpusReader.synonyms.<locals>.<listcomp>ˆ   sF   ø€ ð ð ð àð ˜œ¨Ô0°Ô7×<Ò<Ñ>Ô>Ð?ðð ð r   )r   rC   r9   r?   s   `` r   Úsynonymsz!LinThesaurusCorpusReader.synonymsz   s^   øø€ ð ð 	Ø”? 6Ô*¨5Ô1×6Ò6Ñ8Ô8Ð8ðð ð ð ð à"œmðñ ô ð r   c                 ó:   ‡ ‡— t          ˆˆ fd„‰ j        d¦  «        S )zÔ
        Determines whether or not the given ngram is in the thesaurus.

        :param ngram: ngram to lookup
        :type ngram: C{string}
        :return: whether the given ngram is in the thesaurus.
        c                 ó&   •— | p‰‰j         |         v S ©N)r   )Úaccumr'   r-   r"   s     €€r   ú<lambda>z7LinThesaurusCorpusReader.__contains__.<locals>.<lambda>–   s   ø€  %Ð"M¨E°T´_ÀVÔ5LÐ,L€ r   F)r   r9   )r"   r-   s   ``r   Ú__contains__z%LinThesaurusCorpusReader.__contains__�   s/   øø€ õ ØMÐMÐMÐMÐMØŒMØñ
ô 
ð 	
r   )r   rG   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚreÚcompiler   Ústaticmethodr   r   r:   r@   rD   rJ   Ú__classcell__)r/   s   @r   r   r      s½   ø€ € € € € ØOÐOð ˆbŒjÐ<Ñ=Ô=€Gàð!ð !ñ „\ð!ð"ð "ð "ð "ð "ð "ðH%ð %ð %ð %ðNð ð ð ð(ð ð ð ð&
ð 
ð 
ð 
ð 
ð 
ð 
r   r   c                  ó4  — ddl m}  d}d}t          d|z   ¦  «         t          |                      |¦  «        ¦  «         t          d|z   ¦  «         t          |                      |¦  «        ¦  «         t          d|z   ¦  «         t          |                      |d¬	¦  «        ¦  «         t          d|z   ¦  «         t          |                      |d¬	¦  «        ¦  «         t          d
|› d|› d�¦  «         t          |                      ||¦  «        ¦  «         d S )Nr   )Úlin_thesaurusÚbusinessÚ
enterprisezGetting synonyms for zGetting scored synonyms for z5Getting synonyms from simN.lsp (noun subsection) for zsimN.lsp)r'   zSimilarity score for z and ú:)Únltk.corpusrT   ÚprintrD   r@   r:   )ÚthesÚword1Úword2s      r   Údemor]   ¡   s$  € Ø1Ð1Ð1Ð1Ð1Ð1à€EØ€EÝ	Ð
! EÑ
)Ñ*Ô*Ð*Ý	ˆ$�-Š-˜Ñ
Ô
ÑÔÐå	Ð
(¨5Ñ
0Ñ1Ô1Ð1Ý	ˆ$×
Ò
˜uÑ
%Ô
%Ñ&Ô&Ð&å	Ð
AÀEÑ
IÑJÔJÐJÝ	ˆ$�-Š-˜ jˆ-Ñ
1Ô
1Ñ2Ô2Ð2å	Ð
AÀEÑ
IÑJÔJÐJÝ	ˆ$�-Š-˜ jˆ-Ñ
1Ô
1Ñ2Ô2Ð2å	Ð
6 %Ð
6Ð
6¨eÐ
6Ð
6Ð
6Ñ7Ô7Ð7Ý	ˆ$�/Š/˜% Ñ
'Ô
'Ñ(Ô(Ð(Ð(Ð(r   Ú__main__)
rO   Úcollectionsr   Ú	functoolsr   Únltk.corpus.readerr   r   r]   rK   r
   r   r   ú<module>rb      s¬   ðð 
€	€	€	Ø #Ð #Ð #Ð #Ð #Ð #Ø Ð Ð Ð Ð Ð à +Ð +Ð +Ð +Ð +Ð +ðJ
ð J
ð J
ð J
ð J
˜|ñ J
ô J
ð J
ðd)ð )ð )ð* ˆzÒÐØ€D�F„F€F€F€Fð Ðr   