§
    'ê[fà*  ã                   ó¤   — d dl mZ d dlmZ 	 dgZ	 d dlmZ d dlmZ d„ Z	n# e
$ rZefd„Z	Y dZ[ndZ[ww xY wd	„ Zd
„ Z G d„ de¦  «        Zd„ ZdS )é    )ÚParserI)ÚTreeÚBllipParser)ÚRerankingParser©Úget_unified_model_parametersc                  ó   — d S ©N© r   ó    úD/var/www/piapp/venv/lib/python3.11/site-packages/nltk/parse/bllip.pyÚ_ensure_bllip_import_or_errorr   Z   s   € Øˆr   c                 ó&   — t          d| z  ¦  «        ‚)Nz&Couldn't import bllipparser module: %s)ÚImportError)Úies    r   r   r   _   s   € ÝÐBÀRÑGÑHÔHÐHr   Nc                 ó®   — 	 t          | ¦  «        D ]\  }}|                     d¦  «         Œd S # t          $ r}t          d|› d|›d�¦  «        |‚d }~ww xY w)NÚasciizToken z (zH) is non-ASCII. BLLIP Parser currently doesn't support non-ASCII inputs.)Ú	enumerateÚencodeÚUnicodeEncodeErrorÚ
ValueError)ÚwordsÚiÚwordÚes       r   Ú_ensure_asciir   c   s™   € ðÝ  Ñ'Ô'ð 	!ð 	!‰GˆAˆtØ�KŠK˜Ñ Ô Ð Ð ð	!ð 	!øåð ð ð Ýð:�Qð :ð :˜$ð :ð :ð :ñ
ô 
ð ð	øøøøðøøøs   ‚*. ®
A¸AÁAc                 óN   — t          j        t          | j        ¦  «        ¦  «        S r
   )r   Ú
fromstringÚstrÚ	ptb_parse)Úscored_parses    r   Ú_scored_parse_to_nltk_treer"   n   s   € ÝŒ?�3˜|Ô5Ñ6Ô6Ñ7Ô7Ð7r   c                   óJ   — e Zd ZdZ	 	 	 	 	 dd„Zd„ Zd„ Ze	 dd„¦   «         ZdS )	r   zÑ
    Interface for parsing with BLLIP Parser. BllipParser objects can be
    constructed with the ``BllipParser.from_unified_model_dir`` class
    method or manually using the ``BllipParser`` constructor.
    Nc                 ó¸   — t          ¦   «          |pi }|pi }t          ¦   «         | _         | j        j        |fi |¤Ž |r|r | j        j        d||dœ|¤Ž dS dS dS )aÈ  
        Load a BLLIP Parser model from scratch. You'll typically want to
        use the ``from_unified_model_dir()`` class method to construct
        this object.

        :param parser_model: Path to parser model directory
        :type parser_model: str

        :param reranker_features: Path the reranker model's features file
        :type reranker_features: str

        :param reranker_weights: Path the reranker model's weights file
        :type reranker_weights: str

        :param parser_options: optional dictionary of parser options, see
            ``bllipparser.RerankingParser.RerankingParser.load_parser_options()``
            for more information.
        :type parser_options: dict(str)

        :param reranker_options: optional
            dictionary of reranker options, see
            ``bllipparser.RerankingParser.RerankingParser.load_reranker_model()``
            for more information.
        :type reranker_options: dict(str)
        )Úfeatures_filenameÚweights_filenameNr   )r   r   ÚrrpÚload_parser_modelÚload_reranker_model)ÚselfÚparser_modelÚreranker_featuresÚreranker_weightsÚparser_optionsÚreranker_optionss         r   Ú__init__zBllipParser.__init__y   s±   € õB 	&Ñ'Ô'Ð'à'Ð-¨2ˆØ+Ð1¨rÐå"Ñ$Ô$ˆŒØ"ˆŒÔ" <ÐBÐB°>ÐBÐBÐBØð 	Ð!1ð 	Ø(ˆDŒHÔ(ð Ø"3Ø!1ðð ð #ðð ð ð ð ð	ð 	ð 	ð 	r   c              #   óˆ   K  — t          |¦  «         | j                             |¦  «        }|D ]}t          |¦  «        V — ŒdS )aŸ  
        Use BLLIP Parser to parse a sentence. Takes a sentence as a list
        of words; it will be automatically tagged with this BLLIP Parser
        instance's tagger.

        :return: An iterator that generates parse trees for the sentence
            from most likely to least likely.

        :param sentence: The sentence to be parsed
        :type sentence: list(str)
        :rtype: iter(Tree)
        N)r   r'   Úparser"   )r*   ÚsentenceÚ
nbest_listr!   s       r   r2   zBllipParser.parse¨   sY   è è € õ 	�hÑÔÐØ”X—^’^ HÑ-Ô-ˆ
Ø&ð 	;ð 	;ˆLÝ,¨\Ñ:Ô:Ð:Ð:Ð:Ð:ð	;ð 	;r   c              #   óú   K  — g }i }t          |¦  «        D ]$\  }\  }}|                     |¦  «         |�|||<   Œ%t          |¦  «         | j                             ||¦  «        }|D ]}t          |¦  «        V — ŒdS )a   
        Use BLLIP to parse a sentence. Takes a sentence as a list of
        (word, tag) tuples; the sentence must have already been tokenized
        and tagged. BLLIP will attempt to use the tags provided but may
        use others if it can't come up with a complete parse subject
        to those constraints. You may also specify a tag as ``None``
        to leave a token's tag unconstrained.

        :return: An iterator that generates parse trees for the sentence
            from most likely to least likely.

        :param sentence: Input sentence to parse as (word, tag) pairs
        :type sentence: list(tuple(str, str))
        :rtype: iter(Tree)
        N)r   Úappendr   r'   Úparse_taggedr"   )	r*   Úword_and_tag_pairsr   Útag_mapr   r   Útagr4   r!   s	            r   Útagged_parsezBllipParser.tagged_parseº   s¨   è è € ð  ˆØˆÝ'Ð(:Ñ;Ô;ð 	!ð 	!‰NˆA‰{��cØ�LŠL˜ÑÔÐØˆØ �˜‘
øå�eÑÔÐØ”X×*Ò*¨5°'Ñ:Ô:ˆ
Ø&ð 	;ð 	;ˆLÝ,¨\Ñ:Ô:Ð:Ð:Ð:Ð:ð	;ð 	;r   c                 óF   — t          |¦  «        \  }}} | |||||¦  «        S )a(  
        Create a ``BllipParser`` object from a unified parsing model
        directory. Unified parsing model directories are a standardized
        way of storing BLLIP parser and reranker models together on disk.
        See ``bllipparser.RerankingParser.get_unified_model_parameters()``
        for more information about unified model directories.

        :return: A ``BllipParser`` object using the parser and reranker
            models in the model directory.

        :param model_dir: Path to the unified model directory.
        :type model_dir: str
        :param parser_options: optional dictionary of parser options, see
            ``bllipparser.RerankingParser.RerankingParser.load_parser_options()``
            for more information.
        :type parser_options: dict(str)
        :param reranker_options: optional dictionary of reranker options, see
            ``bllipparser.RerankingParser.RerankingParser.load_reranker_model()``
            for more information.
        :type reranker_options: dict(str)
        :rtype: BllipParser
        r   )ÚclsÚ	model_dirr.   r/   Úparser_model_dirÚreranker_features_filenameÚreranker_weights_filenames          r   Úfrom_unified_model_dirz"BllipParser.from_unified_model_dirÖ   s@   € õ< )¨Ñ3Ô3ñ		
ØØ&Ø%àˆsØØ&Ø%ØØñ
ô 
ð 	
r   )NNNNN)NN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r0   r2   r;   ÚclassmethodrB   r   r   r   r   r   r   s…   € € € € € ðð ð ØØØØð-ð -ð -ð -ð^;ð ;ð ;ð$;ð ;ð ;ð8 à>Bð$
ð $
ð $
ñ „[ð$
ð $
ð $
r   c            	      óº  — ddl m}   | d¦  «        j        }t          d¦  «         t                               |¦  «        }t          d¦  «         d                     ¦   «         }d                     ¦   «         }d                     ¦   «         }|||fD ]x}t          d	d
                     |¦  «        z  ¦  «         	 t          | 	                    |¦  «        ¦  «        }t          |¦  «         ŒZ# t          $ r t          d¦  «         Y Œuw xY wt          | 	                    |¦  «        ¦  «        D ]\  }}	t          d||	fz  ¦  «         Œt          dt          |                     ddg¦  «        ¦  «        ¦  «         t          dt          |                     ddg¦  «        ¦  «        ¦  «         t          dt          |                     ddg¦  «        ¦  «        ¦  «         dS )z8This assumes the Python module bllipparser is installed.r   )Úfindzmodels/bllip_wsj_no_auxzLoading BLLIP Parsing models...zDone.z#British left waffles on Falklands .z"I saw the man with the telescope .z	# ! ? : -zSentence: %rÚ z(parse failed)zparse %d:
%szforcing 'tree' to be 'NN':)ÚAN)ÚtreeÚNNz.forcing 'A' to be 'DT' and 'tree' to be 'NNP':)rK   ÚDT)rL   ÚNNPzforcing 'A' to be 'NNP':)rK   rO   )rL   NN)Ú	nltk.datarI   ÚpathÚprintr   rB   ÚsplitÚjoinÚnextr2   ÚStopIterationr   r;   )
rI   r>   ÚbllipÚ	sentence1Ú	sentence2Úfail1r3   rL   r   r2   s
             r   Údemor[   þ   s  € ð ÐÐÐÐÐà�Ð.Ñ/Ô/Ô4€Iå	Ð
+Ñ,Ô,Ð,å×.Ò.¨yÑ9Ô9€EÝ	ˆ'�N„N€Nà5×;Ò;Ñ=Ô=€IØ4×:Ò:Ñ<Ô<€Ià×ÒÑÔ€EØ 	¨5Ð1ð $ð $ˆÝˆn˜sŸxšx¨Ñ1Ô1Ñ1Ñ2Ô2Ð2ð	$Ý˜Ÿš HÑ-Ô-Ñ.Ô.ˆDÝ�$‰KŒKˆKˆKøÝð 	$ð 	$ð 	$ÝÐ"Ñ#Ô#Ð#Ð#Ð#ð	$øøøõ ˜eŸkšk¨)Ñ4Ô4Ñ5Ô5ð ,ð ,‰ˆˆ5Ýˆo  E 
Ñ*Ñ+Ô+Ð+Ð+õ 
Ø$ÝˆU×Ò ¨nÐ =Ñ>Ô>Ñ?Ô?ñô ð õ 
Ø8ÝˆU×Ò ¨oÐ >Ñ?Ô?Ñ@Ô@ñô ð õ 
Ø"ÝˆU×Ò ¨~Ð >Ñ?Ô?Ñ@Ô@ñô ð ð ð s   Â81C*Ã*DÄD)Únltk.parse.apir   Ú	nltk.treer   Ú__all__Úbllipparserr   Úbllipparser.RerankingParserr   r   r   r   r   r"   r   r[   r   r   r   ú<module>ra      sA  ðð #Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð ðDðL ˆ/€ð
IØ+Ð+Ð+Ð+Ð+Ð+ØHÐHÐHÐHÐHÐHðð ð ð øð ð Ið Ið Ià)+ð Ið Ið Ið Ið Ið Ið Ið Ið IøøøøðIøøøðð ð ð8ð 8ð 8ðI
ð I
ð I
ð I
ð I
�'ñ I
ô I
ð I
ðX-ð -ð -ð -ð -s   ’" ¢6§1±6