Ë
    çÍ:j'  ã                   ó®   — d dl mZmZ d dlmZ d dlmZ e G d„ de¬«      «       Z G d„ de«      Ze G d	„ d
«      «       Z	 G d„ de«      Z
 G d„ de«      Zy)é    )ÚABCMetaÚabstractmethod)Útotal_ordering)Úraise_unorderable_typesc                   óˆ   — e Zd ZdZed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z	ed„ «       Z
d„ Zd	„ Zd
„ Zd„ Zy)ÚAbstractCCGCategoryz;
    Interface for categories in combinatory grammars.
    c                  ó   — y)z<
        Returns true if the category is primitive.
        N© ©Úselfs    úa/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/nltk/ccg/api.pyÚis_primitivez AbstractCCGCategory.is_primitive   ó   � ó    c                  ó   — y)zI
        Returns true if the category is a function application.
        Nr
   r   s    r   Úis_functionzAbstractCCGCategory.is_function   r   r   c                  ó   — y)z=
        Returns true if the category is a variable.
        Nr
   r   s    r   Úis_varzAbstractCCGCategory.is_var    r   r   c                  ó   — y)z–
        Takes a set of (var, category) substitutions, and replaces every
        occurrence of the variable with the corresponding category.
        Nr
   )r   Úsubstitutionss     r   Ú
substitutezAbstractCCGCategory.substitute&   r   r   c                  ó   — y)z·
        Determines whether two categories can be unified.
         - Returns None if they cannot be unified
         - Returns a list of necessary substitutions if they can.
        Nr
   ©r   Úothers     r   Ú	can_unifyzAbstractCCGCategory.can_unify-   r   r   c                  ó   — y ©Nr
   r   s    r   Ú__str__zAbstractCCGCategory.__str__6   s   € àr   c                 óh   — | j                   |j                   u xr | j                  |j                  k(  S r   ©Ú	__class__Ú_comparison_keyr   s     r   Ú__eq__zAbstractCCGCategory.__eq__:   ó0   € à�N‰N˜eŸo™oÐ-ò >Ø×$Ñ$¨×(=Ñ(=Ñ=ð	
r   c                 ó   — | |k(   S r   r
   r   s     r   Ú__ne__zAbstractCCGCategory.__ne__@   ó   € Ø˜5‘=Ð Ð r   c                 óø   — t        |t        «      st        d| |«       | j                  |j                  u r| j                  |j                  k  S | j                  j
                  |j                  j
                  k  S ©Nú<)Ú
isinstancer   r   r!   r"   Ú__name__r   s     r   Ú__lt__zAbstractCCGCategory.__lt__C   s_   € Ü˜%Ô!4Ô5Ü# C¨¨uÔ5Ø�>‰>˜UŸ_™_Ñ,Ø×'Ñ'¨%×*?Ñ*?Ñ?Ð?à—>‘>×*Ñ*¨U¯_©_×-EÑ-EÑEÐEr   c                 ó†   — 	 | j                   S # t        $ r) t        | j                  «      | _         | j                   cY S w xY wr   ©Ú_hashÚAttributeErrorÚhashr"   r   s    r   Ú__hash__zAbstractCCGCategory.__hash__K   ó<   € ð	Ø—:‘:ÐøÜò 	Ü˜d×2Ñ2Ó3ˆDŒJØ—:‘:Òð	úó   ‚ Ž/A ¿A N)r,   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r#   r&   r-   r3   r
   r   r   r   r      s”   „ ñð ñó ðð
 ñó ðð
 ñó ðð
 ñó ðð ñó ðð ñó ðò
ò!òFór   r   )Ú	metaclassc                   óf   — e Zd ZdZdZdd„Zed„ «       Zed„ «       Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zd„ Zd„ Zy)ÚCCGVarz�
    Class representing a variable CCG category.
    Used for conjunctions (and possibly type-raising, if implemented as a
    unary rule).
    r   c                 ó^   — | j                  «       | _        || _        | j                  | _        y)z×Initialize a variable (selects a new identifier)

        :param prim_only: a boolean that determines whether the variable is
                          restricted to primitives
        :type prim_only: bool
        N)Únew_idÚ_idÚ
_prim_onlyr"   )r   Ú	prim_onlys     r   Ú__init__zCCGVar.__init__\   s$   € ð —;‘;“=ˆŒØ#ˆŒØ#Ÿx™xˆÕr   c                 óH   — | j                   dz   | _         | j                   dz
  S )zT
        A class method allowing generation of unique variable identifiers.
        é   ©Ú_maxID©Úclss    r   r=   zCCGVar.new_idg   s!   € ð
 —Z‘Z !‘^ˆŒ
Ø�z‰z˜A‰~Ðr   c                 ó   — d| _         y )Nr   rD   rF   s    r   Úreset_idzCCGVar.reset_ido   s	   € àˆ�
r   c                  ó   — y©NFr
   r   s    r   r   zCCGVar.is_primitives   ó   € Ør   c                  ó   — yrK   r
   r   s    r   r   zCCGVar.is_functionv   rL   r   c                  ó   — y©NTr
   r   s    r   r   zCCGVar.is_vary   ó   € Ør   c                 ó,   — |D ]  \  }}|| k(  sŒ|c S  | S )zlIf there is a substitution corresponding to this variable,
        return the substituted category.
        r
   )r   r   ÚvarÚcats       r   r   zCCGVar.substitute|   s*   € ð &ò 	‰HˆC�Ø�d‹{Ø’
ð	ð ˆr   c                 óF   — |j                  «       s| j                  s| |fgS y)zWIf the variable can be replaced with other
        a substitution is returned.
        N)r   r?   r   s     r   r   zCCGVar.can_unify…   s%   € ð ×ÑÔ t§¢Ø˜5�M�?Ð"Ør   c                 ó   — | j                   S r   )r>   r   s    r   Úidz	CCGVar.id�   s   € Ø�x‰xˆr   c                 ó2   — dt        | j                  «      z   S )NÚ_var)Ústrr>   r   s    r   r   zCCGVar.__str__�   s   € Øœ˜DŸH™H›Ñ%Ð%r   N)F)r,   r6   r7   r8   rE   rA   Úclassmethodr=   rI   r   r   r   r   r   rV   r   r
   r   r   r;   r;   S   s^   „ ñð €Fó	(ð ñó ðð ñó ðòòòòòòó&r   r;   c                   óp   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)Ú	Directionz¨
    Class representing the direction of a function application.
    Also contains maintains information as to which combinators
    may be used with the category.
    c                 óD   — || _         || _        |t        |«      f| _        y r   )Ú_dirÚ_restrsÚtupler"   )r   ÚdirÚrestrictionss      r   rA   zDirection.__init__œ   s"   € ØˆŒ	Ø#ˆŒØ #¤U¨<Ó%8Ð9ˆÕr   c                 ó    — | j                   dk(  S )Nú/©r^   r   s    r   Ú
is_forwardzDirection.is_forward¢   s   € Ø�y‰y˜CÑÐr   c                 ó    — | j                   dk(  S )Nú\re   r   s    r   Úis_backwardzDirection.is_backward¥   s   € Ø�y‰y˜DÑ Ð r   c                 ó   — | j                   S r   re   r   s    r   ra   zDirection.dir¨   ó   € Ø�y‰yÐr   c                 ó   — | j                   S )a8  A list of restrictions on the combinators.
        '.' denotes that permuting operations are disallowed
        ',' denotes that function composition is disallowed
        '_' denotes that the direction has variable restrictions.
        (This is redundant in the current implementation of type-raising)
        ©r_   r   s    r   ÚrestrszDirection.restrs«   s   € ð �|‰|Ðr   c                 ó    — | j                   dk(  S ©NÚ_rm   r   s    r   Úis_variablezDirection.is_variable´   s   € Ø�|‰|˜sÑ"Ð"r   c                 óÖ   — |j                  «       rd| j                  «       fgS | j                  «       rd|j                  «       fgS | j                  «       |j                  «       k(  rg S y rp   )rr   rn   r   s     r   r   zDirection.can_unifyº   s^   € Ø×ÑÔØ˜$Ÿ+™+›-Ð(Ð)Ð)Ø×ÑÔØ˜%Ÿ,™,›.Ð)Ð*Ð*à�{‰{‹} §¡£Ò.Ø�	Ør   c                 óx   — | j                  «       s| S |D ]"  \  }}|dk(  sŒt        | j                  |«      c S  | S rp   )rr   r\   r^   )r   ÚsubsrR   rn   s       r   r   zDirection.substituteÄ   sE   € Ø×ÑÔ!ØˆKàò 	4‰KˆC�Ø�c‹zÜ  §¡¨FÓ3Ò3ð	4ð ˆr   c                 ó   — d| j                   vS )Nú,rm   r   s    r   Úcan_composezDirection.can_composeÎ   ó   € Ø˜$Ÿ,™,Ð&Ð&r   c                 ó   — d| j                   vS )Nú.rm   r   s    r   Ú	can_crosszDirection.can_crossÑ   ry   r   c                 óh   — | j                   |j                   u xr | j                  |j                  k(  S r   r    r   s     r   r#   zDirection.__eq__Ô   r$   r   c                 ó   — | |k(   S r   r
   r   s     r   r&   zDirection.__ne__Ú   r'   r   c                 óø   — t        |t        «      st        d| |«       | j                  |j                  u r| j                  |j                  k  S | j                  j
                  |j                  j
                  k  S r)   )r+   r\   r   r!   r"   r,   r   s     r   r-   zDirection.__lt__Ý   s^   € Ü˜%¤Ô+Ü# C¨¨uÔ5Ø�>‰>˜UŸ_™_Ñ,Ø×'Ñ'¨%×*?Ñ*?Ñ?Ð?à—>‘>×*Ñ*¨U¯_©_×-EÑ-EÑEÐEr   c                 ó†   — 	 | j                   S # t        $ r) t        | j                  «      | _         | j                   cY S w xY wr   r/   r   s    r   r3   zDirection.__hash__å   r4   r5   c                 óX   — d}| j                   D ]
  }|d|z  z   }Œ | j                  › |› �S )NÚ ú%s)r_   r^   )r   Úr_strÚrs      r   r   zDirection.__str__ì   s;   € ØˆØ—‘ò 	%ˆAØ˜D 1™HÑ$‰Eð	%à—)‘)�˜U˜GÐ$Ð$r   c                 óx   — | j                   dk(  rt        d| j                  «      S t        d| j                  «      S )Nrd   rh   )r^   r\   r_   r   s    r   Ú__neg__zDirection.__neg__ó   s0   € Ø�9‰9˜ÒÜ˜T 4§<¡<Ó0Ð0ä˜S $§,¡,Ó/Ð/r   N)r,   r6   r7   r8   rA   rf   ri   ra   rn   rr   r   r   rx   r|   r#   r&   r-   r3   r   r‡   r
   r   r   r\   r\   ”   sX   „ ñò:ò ò!òòò#òòò'ò'ò
ò!òFòò%ó0r   r\   c                   óJ   — e Zd ZdZg fd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zy)ÚPrimitiveCategoryz«
    Class representing primitive categories.
    Takes a string representation of the category, and a
    list of strings specifying the morphological subcategories.
    c                 óD   — || _         || _        |t        |«      f| _        y r   )Ú_categr_   r`   r"   )r   Úcategrb   s      r   rA   zPrimitiveCategory.__init__  s"   € ØˆŒØ#ˆŒØ %¤u¨\Ó':Ð;ˆÕr   c                  ó   — yrO   r
   r   s    r   r   zPrimitiveCategory.is_primitive  rP   r   c                  ó   — yrK   r
   r   s    r   r   zPrimitiveCategory.is_function	  rL   r   c                  ó   — yrK   r
   r   s    r   r   zPrimitiveCategory.is_var  rL   r   c                 ó   — | j                   S r   rm   r   s    r   rn   zPrimitiveCategory.restrs  s   € Ø�|‰|Ðr   c                 ó   — | j                   S r   )r‹   r   s    r   rŒ   zPrimitiveCategory.categ  s   € Ø�{‰{Ðr   c                 ó   — | S r   r
   )r   ru   s     r   r   zPrimitiveCategory.substitute  s   € Øˆr   c                 óà   — |j                  «       sy |j                  «       r|| fgS |j                  «       | j                  «       k(  r'| j                  D ]  }||j	                  «       vsŒ y  g S y r   )r   r   rŒ   r_   rn   )r   r   Úrestrs      r   r   zPrimitiveCategory.can_unify  sh   € Ø×!Ñ!Ô#ØØ�<‰<Œ>Ø˜D�M�?Ð"Ø�;‰;‹=˜DŸJ™J›LÒ(ØŸ™ò  �Ø §¡£Ò.Ùð ð ˆIØr   c                 ó¨   — | j                   g k(  rd| j                  z  S ddj                  d„ | j                   D «       «      z  }| j                  › |› �S )Nrƒ   z[%s]rw   c              3   ó2   K  — | ]  }t        |«      –— Œ y ­wr   )Úrepr)Ú.0r…   s     r   ú	<genexpr>z,PrimitiveCategory.__str__.<locals>.<genexpr>+  s   è ø€ Ò(G°Q¬¨a¯Ñ(Gùs   ‚)r_   r‹   Újoin)r   rb   s     r   r   zPrimitiveCategory.__str__(  sM   € Ø�<‰<˜2ÒØ˜$Ÿ+™+Ñ%Ð%Ø §¡Ñ(G¸$¿,¹,Ô(GÓ GÑGˆØ—+‘+�˜|˜nÐ-Ð-r   N)r,   r6   r7   r8   rA   r   r   r   rn   rŒ   r   r   r   r
   r   r   r‰   r‰   ú   s9   „ ñð ,.ó <ò
òòòòòò
ó.r   r‰   c                   óL   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zy)ÚFunctionalCategoryzœ
    Class that represents a function application category.
    Consists of argument and result categories, together with
    an application direction.
    c                 óB   — || _         || _        || _        |||f| _        y r   )Ú_resÚ_argr^   r"   )r   ÚresÚargra   s       r   rA   zFunctionalCategory.__init__6  s%   € ØˆŒ	ØˆŒ	ØˆŒ	Ø # S¨#˜ˆÕr   c                  ó   — yrK   r
   r   s    r   r   zFunctionalCategory.is_primitive<  rL   r   c                  ó   — yrO   r
   r   s    r   r   zFunctionalCategory.is_function?  rP   r   c                  ó   — yrK   r
   r   s    r   r   zFunctionalCategory.is_varB  rL   r   c                 óÒ   — | j                   j                  |«      }| j                  j                  |«      }| j                  j                  |«      }t	        ||| j                  «      S r   )rž   r   r^   rŸ   rœ   )r   ru   Úsub_resÚsub_dirÚsub_args        r   r   zFunctionalCategory.substituteG  sQ   € Ø—)‘)×&Ñ& tÓ,ˆØ—)‘)×&Ñ& tÓ,ˆØ—)‘)×&Ñ& tÓ,ˆÜ! '¨7°D·I±IÓ>Ð>r   c                 ó–  — |j                  «       r|| fgS |j                  «       r¤| j                  j                  |j	                  «       «      }| j
                  j                  |j                  «       «      }|�P|�N| j                  j                  |«      j                  |j                  «       j                  |«      «      }|�||z   S y r   )
r   r   rž   r   r    r^   ra   rŸ   r   r¡   )r   r   ÚsaÚsdÚsbs        r   r   zFunctionalCategory.can_unifyO  s¡   € Ø�<‰<Œ>Ø˜D�M�?Ð"Ø×ÑÔØ—‘×$Ñ$ U§Y¡Y£[Ó1ˆBØ—‘×$Ñ$ U§Y¡Y£[Ó1ˆBØˆ~ " .Ø—Y‘Y×)Ñ)¨"Ó-×7Ñ7¸¿	¹	»×8NÑ8NÈrÓ8RÓS�Ø�>Ø ™7�NØr   c                 ó   — | j                   S r   )rŸ   r   s    r   r¡   zFunctionalCategory.arg\  rk   r   c                 ó   — | j                   S r   )rž   r   s    r   r    zFunctionalCategory.res_  rk   r   c                 ó   — | j                   S r   re   r   s    r   ra   zFunctionalCategory.dirb  rk   r   c                 óR   — d| j                   › | j                  › | j                  › d�S )Nú(ú))rž   r^   rŸ   r   s    r   r   zFunctionalCategory.__str__e  s%   € Ø�4—9‘9�+˜dŸi™i˜[¨¯©¨°1Ð5Ð5r   N)r,   r6   r7   r8   rA   r   r   r   r   r   r¡   r    ra   r   r
   r   r   rœ   rœ   /  s9   „ ñò/òòòò
?ò
òòòó6r   rœ   N)Úabcr   r   Ú	functoolsr   Únltk.internalsr   r   r;   r\   r‰   rœ   r
   r   r   ú<module>r¶      su   ð÷ (Ý $å 2ð ôA Gô Aó ðAôH>&Ð ô >&ðB ÷b0ð b0ó ðb0ôJ2.Ð+ô 2.ôj76Ð,õ 76r   