Ë
    çÍ:jö  ã                   ól   — d dl mZ d dlmZ d dlmZmZmZ  G d„ d«      Zd
d„Z	d„ Z
ed	k(  r e
«        yy)é    )Úload_parser)ÚInstantiateVarsChart)ÚApplicationExpressionÚLambdaExpressionÚVariablec                   ó$   — e Zd ZdZd„ Zd„ Zdd„Zy)ÚCooperStorezK
    A container for handling quantifier ambiguity via Cooper storage.
    c                 ó„   — || _         g | _        	 |d   | _        |d   | _        y# t        $ r t        d|z  «       Y yw xY w)zÃ
        :param featstruct: The value of the ``sem`` node in a tree from
            ``parse_with_bindops()``
        :type featstruct: FeatStruct (with features ``core`` and ``store``)

        ÚCOREÚSTOREz$%s is not a Cooper storage structureN)Ú
featstructÚreadingsÚcoreÚstoreÚKeyErrorÚprint)Úselfr   s     úl/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/nltk/sem/cooper_storage.pyÚ__init__zCooperStore.__init__   sO   € ð %ˆŒØˆŒð	GØ" 6Ñ*ˆDŒIØ# GÑ,ˆD�JøÜò 	GÜÐ8¸:ÑEÖFð	Gús   �% ¥?¾?c              #   ó�   K  — d„ }|r9t        |«      D ]*  \  }}| j                   |||«      «      D ]
  }|f|z   –— Œ Œ, yd–— y­w)z{
        :return: An iterator over the permutations of the input list
        :type lst: list
        :rtype: iter
        c                 ó   — | d | | |dz   d  z   S )Né   © )Úlst0Úindexs     r   ú<lambda>z&CooperStore._permute.<locals>.<lambda>'   s   €  T¨&¨5 \°D¸À¹¸Ð4EÑ%E€ ó    r   N)Ú	enumerateÚ_permute)r   ÚlstÚremover   ÚxÚys         r   r   zCooperStore._permute!   sY   è ø€ ñ FˆÙÜ% c›Nò #‘��qØŸ™¡v¨c°5Ó'9Ó:ò #�AØ˜$ ™(“Nñ#ñ#ð ‹Hùs   ‚AAc           	      óŠ  — t        | j                  | j                  «      «      D ]œ  \  }}|rt        d|dz   z  «       | j                  }|D ]X  }t        |j                  «      \  }}t        |t        |j                  |«      «      }|rt        d|«       |j                  «       }ŒZ | j                  j                  |«       Œž y)aI  
        Carry out S-Retrieval of binding operators in store. If hack=True,
        serialize the bindop and core as strings and reparse. Ugh.

        Each permutation of the store (i.e. list of binding operators) is
        taken to be a possible scoping of quantifiers. We iterate through the
        binding operators in each permutation, and successively apply them to
        the current term, starting with the core semantic representation,
        working from the inside out.

        Binding operators are of the form::

             bo(\P.all x.(man(x) -> P(x)),z1)
        zPermutation %sr   z  N)r   r   r   r   r   ÚtupleÚargsr   r   ÚvariableÚsimplifyr   Úappend)r   ÚtraceÚpermÚ
store_permÚtermÚbindopÚquantÚvarexs           r   Ú
s_retrievezCooperStore.s_retrieve/   s´   € ô !*¨$¯-©-¸¿
¹
Ó*CÓ Dò 	'ÑˆD�*ÙÜÐ&¨$°©(Ñ3Ô4Ø—9‘9ˆDØ$ò 
'�ä$ V§[¡[Ó1‘��uô -ØÔ+¨E¯N©N¸DÓAó�ñ Ü˜$ Ô%Ø—}‘}“‘ð
'ð �M‰M× Ñ  Õ&ñ	'r   N)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r1   r   r   r   r	   r	      s   „ ñòGòô'r   r	   Nc                 ó‚   — |sd}t        ||t        ¬«      }| j                  «       }t        |j	                  |«      «      S )zC
    Use a grammar with Binding Operators to parse a sentence.
    z#grammars/book_grammars/storage.fcfg)r*   Úchart_class)r   r   ÚsplitÚlistÚparse)ÚsentenceÚgrammarr*   ÚparserÚtokenss        r   Úparse_with_bindopsr?   P   s;   € ñ Ø7ˆÜ˜¨Ô;OÔP€Fà�^‰^Ó€FÜ�—‘˜VÓ$Ó%Ð%r   c                  ó¨  — ddl m}  d}t        «        t        d|z  «       t        d«       | j                  |d¬«      }|D �]  }| j	                  |j                  «       d   «      }t        «        t        d«       t        d	«       |j                  D ]  }t        |«       Œ t        «        t        d
«       t        d	«       t        |j                  «       t        «        t        d«       t        d	«       |j                  d¬«       t        d«       t        d	«       t        |j                  «      D ]  \  }}t        |dz   › d|› �«       Œ �Œ y )Nr   )Úcooper_storagezevery girl chases a dogzAnalysis of sentence '%s'z2==================================================)r*   ÚSEMzBinding operators:z---------------zCore:zS-Retrieval:Tz	Readings:r   z: )Únltk.semrA   r   r?   r	   Úlabelr   r   r1   r   r   )Úcsr;   ÚtreesÚtreeÚsemrepÚsÚiÚreadings           r   ÚdemorL   \   s  € Ý-à(€Hä	„GÜ	Ð
%¨Ñ
0Ô1Ü	ˆ(„OØ×!Ñ! (°!Ð!Ó4€EØó )ˆØ—‘ §
¡
£¨UÑ 3Ó4ˆÜŒÜÐ"Ô#ÜˆhŒØ—‘ò 	ˆAÜ�!�Hð	äŒÜˆgŒÜˆhŒÜˆf�k‰kÔÜŒÜˆnÔÜˆhŒØ×Ñ ÐÔ%ÜˆkÔÜˆhŒä# F§O¡OÓ4ò 	)‰JˆAˆwÜ�Q˜‘U�G˜2˜g˜YÐ'Õ(ò	)ñ%)r   Ú__main__)Nr   )Ú
nltk.parser   Únltk.parse.featurechartr   Únltk.sem.logicr   r   r   r	   r?   rL   r2   r   r   r   ú<module>rQ      s>   ðõ #Ý 8ß LÑ L÷@'ñ @'óF	&ò)ð> ˆzÒÙ…Fð r   