ó
    ´OÂf'  ã                   ó¨   • S SK JrJr  S SKJr  S SKJr  \ " S S\S95       r " S S\5      r\ " S	 S
5      5       r	 " S S\5      r
 " S S\5      rg)é    )ÚABCMetaÚabstractmethod)Útotal_ordering)Úraise_unorderable_typesc                   ó�   • \ rS rSrSr\S 5       r\S 5       r\S 5       r\S 5       r	\S 5       r
\S 5       rS	 rS
 rS rS rSrg)ÚAbstractCCGCategoryé   z3
Interface for categories in combinatory grammars.
c                 ó   • g)z,
Returns true if the category is primitive.
N© ©Úselfs    Ú./usr/lib/python3/dist-packages/nltk/ccg/api.pyÚis_primitiveÚ AbstractCCGCategory.is_primitive   ó   � ó    c                 ó   • g)z9
Returns true if the category is a function application.
Nr   r   s    r   Úis_functionÚAbstractCCGCategory.is_function   r   r   c                 ó   • g)z-
Returns true if the category is a variable.
Nr   r   s    r   Úis_varÚAbstractCCGCategory.is_var    r   r   c                 ó   • g)z~
Takes a set of (var, category) substitutions, and replaces every
occurrence of the variable with the corresponding category.
Nr   )r   Úsubstitutionss     r   Ú
substituteÚAbstractCCGCategory.substitute&   r   r   c                 ó   • g)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_unifyÚAbstractCCGCategory.can_unify-   r   r   c                 ó   • g ©Nr   r   s    r   Ú__str__ÚAbstractCCGCategory.__str__6   s   € àr   c                 ór   • U R                   UR                   L =(       a    U R                  UR                  :H  $ r#   ©Ú	__class__Ú_comparison_keyr   s     r   Ú__eq__ÚAbstractCCGCategory.__eq__:   ó0   € à�N‰N˜eŸo™oÐ-÷ >Ø×$Ñ$¨×(=Ñ(=Ñ=ð	
r   c                 ó   • X:X  + $ r#   r   r   s     r   Ú__ne__ÚAbstractCCGCategory.__ne__@   ó   € ØÒ Ð r   c                 ó  • [        U[        5      (       d  [        SX5        U R                  UR                  L a  U R                  UR                  :  $ U R                  R
                  UR                  R
                  :  $ ©NÚ<)Ú
isinstancer   r   r(   r)   Ú__name__r   s     r   Ú__lt__ÚAbstractCCGCategory.__lt__C   s`   € Ü˜%Ô!4×5Ñ5Ü# C¨Ô5Ø�>‰>˜UŸ_™_Ò,Ø×'Ñ'¨%×*?Ñ*?Ñ?Ð?à—>‘>×*Ñ*¨U¯_©_×-EÑ-EÑEÐEr   c                 óˆ   •  U R                   $ ! [         a)    [        U R                  5      U l         U R                   s $ f = fr#   ©Ú_hashÚAttributeErrorÚhashr)   r   s    r   Ú__hash__ÚAbstractCCGCategory.__hash__K   ó<   € ð	Ø—:‘:ÐøÜó 	Ü˜d×2Ñ2Ó3ˆDŒJØ—:‘:Òð	úó   ‚ Ž0AÁ A)r:   N)r5   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r   r   r    r$   r*   r.   r6   r=   Ú__static_attributes__r   r   r   r   r      s”   † ñð ñó ðð
 ñó ðð
 ñó ðð
 ñó ðð ñó ðð ñó ðò
ò!òFõr   r   )Ú	metaclassc                   óp   • \ rS rSrSrSrSS jr\S 5       r\S 5       r	S r
S rS	 rS
 rS rS rS rSrg)ÚCCGVaréS   z€
Class representing a variable CCG category.
Used for conjunctions (and possibly type-raising, if implemented as a
unary rule).
r   c                 ó\   • U R                  5       U l        Xl        U R                  U l        g)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__ÚCCGVar.__init__\   s"   € ð —;‘;“=ˆŒØ#ŒØ#Ÿx™xˆÕr   c                 óH   • U R                   S-   U l         U R                   S-
  $ )zD
A class method allowing generation of unique variable identifiers.
é   ©Ú_maxID©Úclss    r   rK   ÚCCGVar.new_idg   s!   € ð
 —Z‘Z !‘^ˆŒ
Ø�z‰z˜A‰~Ðr   c                 ó   • SU l         g )Nr   rS   rU   s    r   Úreset_idÚCCGVar.reset_ido   s	   € àˆ�
r   c                 ó   • g©NFr   r   s    r   r   ÚCCGVar.is_primitives   ó   € Ør   c                 ó   • gr\   r   r   s    r   r   ÚCCGVar.is_functionv   r^   r   c                 ó   • g©NTr   r   s    r   r   ÚCCGVar.is_vary   ó   € Ør   c                 ó.   • U H  u  p#X :X  d  M  Us  $    U $ )z\If there is a substitution corresponding to this variable,
return the substituted category.
r   )r   r   ÚvarÚcats       r   r   ÚCCGVar.substitute|   s!   € ó &‰HˆCØ�{Ø’
ñ &ð ˆr   c                 óX   • UR                  5       (       d  U R                  (       d  X4/$ g)zGIf the variable can be replaced with other
a substitution is returned.
N)r   rM   r   s     r   r    ÚCCGVar.can_unify…   s&   € ð ×Ñ×Ñ t§§Ø�M�?Ð"Ør   c                 ó   • U R                   $ r#   )rL   r   s    r   ÚidÚ	CCGVar.id�   s   € Ø�x‰xˆr   c                 ó2   • S[        U R                  5      -   $ )NÚ_var)ÚstrrL   r   s    r   r$   ÚCCGVar.__str__�   s   € Øœ˜DŸH™H›Ñ%Ð%r   )r)   rL   rM   N)F)r5   rA   rB   rC   rD   rT   rO   ÚclassmethodrK   rY   r   r   r   r   r    rl   r$   rE   r   r   r   rH   rH   S   s^   † ñð €Fô	(ð ñó ðð ñó ðòòòòòòõ&r   rH   c                   óx   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rSrg)Ú	Directioné”   z˜
Class representing the direction of a function application.
Also contains maintains information as to which combinators
may be used with the category.
c                 ó@   • Xl         X l        U[        U5      4U l        g r#   )Ú_dirÚ_restrsÚtupler)   )r   ÚdirÚrestrictionss      r   rO   ÚDirection.__init__œ   s   € ØŒ	Ø#ŒØ #¤U¨<Ó%8Ð9ˆÕr   c                 ó    • U R                   S:H  $ )NÚ/©rw   r   s    r   Ú
is_forwardÚDirection.is_forward¢   s   € Ø�y‰y˜CÑÐr   c                 ó    • U R                   S:H  $ )NÚ\r   r   s    r   Úis_backwardÚDirection.is_backward¥   s   € Ø�y‰y˜DÑ Ð r   c                 ó   • U R                   $ r#   r   r   s    r   rz   ÚDirection.dir¨   ó   € Ø�y‰yÐr   c                 ó   • U R                   $ )a  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)
©rx   r   s    r   ÚrestrsÚDirection.restrs«   s   € ð �|‰|Ðr   c                 ó    • U R                   S:H  $ ©NÚ_rŠ   r   s    r   Úis_variableÚDirection.is_variable´   s   € Ø�|‰|˜sÑ"Ð"r   c                 óì   • UR                  5       (       a  SU R                  5       4/$ U R                  5       (       a  SUR                  5       4/$ U R                  5       UR                  5       :X  a  / $ g rŽ   )r�   r‹   r   s     r   r    ÚDirection.can_unifyº   sd   € Ø×Ñ×ÑØ˜$Ÿ+™+›-Ð(Ð)Ð)Ø×Ñ×ÑØ˜%Ÿ,™,›.Ð)Ð*Ð*à�{‰{‹} §¡£Ó.Ø�	Ør   c                 ó†   • U R                  5       (       d  U $ U H#  u  p#US:X  d  M  [        U R                  U5      s  $    U $ rŽ   )r�   rt   rw   )r   Úsubsrf   r‹   s       r   r   ÚDirection.substituteÄ   sA   € Ø×Ñ×!Ñ!ØˆKã‰KˆCØ�c�zÜ  §¡¨FÓ3Ò3ñ  ð ˆr   c                 ó    • SU R                   ;  $ )NÚ,rŠ   r   s    r   Úcan_composeÚDirection.can_composeÎ   ó   € Ø˜$Ÿ,™,Ñ&Ð&r   c                 ó    • SU R                   ;  $ )NÚ.rŠ   r   s    r   Ú	can_crossÚDirection.can_crossÑ   r›   r   c                 ór   • U R                   UR                   L =(       a    U R                  UR                  :H  $ r#   r'   r   s     r   r*   ÚDirection.__eq__Ô   r,   r   c                 ó   • X:X  + $ r#   r   r   s     r   r.   ÚDirection.__ne__Ú   r0   r   c                 ó  • [        U[        5      (       d  [        SX5        U R                  UR                  L a  U R                  UR                  :  $ U R                  R
                  UR                  R
                  :  $ r2   )r4   rt   r   r(   r)   r5   r   s     r   r6   ÚDirection.__lt__Ý   s_   € Ü˜%¤×+Ñ+Ü# C¨Ô5Ø�>‰>˜UŸ_™_Ò,Ø×'Ñ'¨%×*?Ñ*?Ñ?Ð?à—>‘>×*Ñ*¨U¯_©_×-EÑ-EÑEÐEr   c                 óˆ   •  U R                   $ ! [         a)    [        U R                  5      U l         U R                   s $ f = fr#   r9   r   s    r   r=   ÚDirection.__hash__å   r?   r@   c                 ó\   • SnU R                    H  nUSU-  -   nM     U R                   U 3$ )NÚ ú%s)rx   rw   )r   Úr_strÚrs      r   r$   ÚDirection.__str__ì   s6   € ØˆØ—”ˆAØ˜D 1™HÑ$ŠEñ à—)‘)�˜U˜GÐ$Ð$r   c                 óz   • U R                   S:X  a  [        SU R                  5      $ [        SU R                  5      $ )Nr~   rƒ   )rw   rt   rx   r   s    r   Ú__neg__ÚDirection.__neg__ó   s0   € Ø�9‰9˜ÓÜ˜T 4§<¡<Ó0Ð0ä˜S $§,¡,Ó/Ð/r   )r)   rw   r:   rx   N)r5   rA   rB   rC   rD   rO   r€   r„   rz   r‹   r�   r    r   r™   rž   r*   r.   r6   r=   r$   r¯   rE   r   r   r   rt   rt   ”   sX   † ñò:ò ò!òòò#òòò'ò'ò
ò!òFòò%õ0r   rt   c                   óT   • \ rS rSrSr/ 4S jrS rS rS rS r	S r
S	 rS
 rS rSrg)ÚPrimitiveCategoryéú   z›
Class representing primitive categories.
Takes a string representation of the category, and a
list of strings specifying the morphological subcategories.
c                 ó@   • Xl         X l        U[        U5      4U l        g r#   )Ú_categrx   ry   r)   )r   Úcategr{   s      r   rO   ÚPrimitiveCategory.__init__  s   € ØŒØ#ŒØ %¤u¨\Ó':Ð;ˆÕr   c                 ó   • grb   r   r   s    r   r   ÚPrimitiveCategory.is_primitive  rd   r   c                 ó   • gr\   r   r   s    r   r   ÚPrimitiveCategory.is_function	  r^   r   c                 ó   • gr\   r   r   s    r   r   ÚPrimitiveCategory.is_var  r^   r   c                 ó   • U R                   $ r#   rŠ   r   s    r   r‹   ÚPrimitiveCategory.restrs  s   € Ø�|‰|Ðr   c                 ó   • U R                   $ r#   )rµ   r   s    r   r¶   ÚPrimitiveCategory.categ  s   € Ø�{‰{Ðr   c                 ó   • U $ r#   r   )r   r•   s     r   r   ÚPrimitiveCategory.substitute  s   € Øˆr   c                 óú   • UR                  5       (       d  g UR                  5       (       a  X4/$ UR                  5       U R                  5       :X  a*  U R                   H  nX!R	                  5       ;  d  M    g    / $ g r#   )r   r   r¶   rx   r‹   )r   r   Úrestrs      r   r    ÚPrimitiveCategory.can_unify  sd   € Ø×!Ñ!×#Ñ#ØØ�<‰<�>‰>Ø�M�?Ð"Ø�;‰;‹=˜DŸJ™J›LÓ(ØŸœ�Ø§¡£Õ.Ùñ &ð ˆIØr   c                 óª   • U R                   / :X  a  SU R                  -  $ SSR                  S U R                    5       5      -  nU R                   U 3$ )Nrª   z[%s]r˜   c              3   ó8   #   • U  H  n[        U5      v •  M     g 7fr#   )Úrepr)Ú.0r¬   s     r   Ú	<genexpr>Ú,PrimitiveCategory.__str__.<locals>.<genexpr>+  s   é € Ð(Gº,°Q¬¨a¯¨º,ùs   ‚)rx   rµ   Újoin)r   r{   s     r   r$   ÚPrimitiveCategory.__str__(  sM   € Ø�<‰<˜2ÓØ˜$Ÿ+™+Ñ%Ð%Ø §¡Ñ(G¸$¿,º,Ó(GÓ GÑGˆØ—+‘+�˜|˜nÐ-Ð-r   )rµ   r)   rx   N)r5   rA   rB   rC   rD   rO   r   r   r   r‹   r¶   r   r    r$   rE   r   r   r   r²   r²   ú   s9   † ñð ,.ô <ò
òòòòòò
õ.r   r²   c                   óT   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rSrg)ÚFunctionalCategoryi/  zŒ
Class that represents a function application category.
Consists of argument and result categories, together with
an application direction.
c                 ó:   • Xl         X l        X0l        X#U4U l        g r#   )Ú_resÚ_argrw   r)   )r   ÚresÚargrz   s       r   rO   ÚFunctionalCategory.__init__6  s   € ØŒ	ØŒ	ØŒ	Ø #¨#˜ˆÕr   c                 ó   • gr\   r   r   s    r   r   ÚFunctionalCategory.is_primitive<  r^   r   c                 ó   • grb   r   r   s    r   r   ÚFunctionalCategory.is_function?  rd   r   c                 ó   • gr\   r   r   s    r   r   ÚFunctionalCategory.is_varB  r^   r   c                 óÐ   • U R                   R                  U5      nU R                  R                  U5      nU R                  R                  U5      n[	        X$U R                  5      $ r#   )rÒ   r   rw   rÓ   rÐ   )r   r•   Úsub_resÚsub_dirÚsub_args        r   r   ÚFunctionalCategory.substituteG  sO   € Ø—)‘)×&Ñ& tÓ,ˆØ—)‘)×&Ñ& tÓ,ˆØ—)‘)×&Ñ& tÓ,ˆÜ! '°D·I±IÓ>Ð>r   c                 ó¬  • UR                  5       (       a  X4/$ UR                  5       (       a¦  U R                  R                  UR	                  5       5      nU R
                  R                  UR                  5       5      nUbQ  UbN  U R                  R                  U5      R                  UR                  5       R                  U5      5      nUb  X$-   $ g r#   )
r   r   rÒ   r    rÔ   rw   rz   rÓ   r   rÕ   )r   r   ÚsaÚsdÚsbs        r   r    ÚFunctionalCategory.can_unifyO  s¢   € Ø�<‰<�>‰>Ø�M�?Ð"Ø×Ñ×ÑØ—‘×$Ñ$ U§Y¡Y£[Ó1ˆBØ—‘×$Ñ$ U§Y¡Y£[Ó1ˆBØ‰~ "¡.Ø—Y‘Y×)Ñ)¨"Ó-×7Ñ7¸¿	¹	»×8NÑ8NÈrÓ8RÓS�Ø‘>Ø™7�NØr   c                 ó   • U R                   $ r#   )rÓ   r   s    r   rÕ   ÚFunctionalCategory.arg\  rˆ   r   c                 ó   • U R                   $ r#   )rÒ   r   s    r   rÔ   ÚFunctionalCategory.res_  rˆ   r   c                 ó   • U R                   $ r#   r   r   s    r   rz   ÚFunctionalCategory.dirb  rˆ   r   c                 óR   • SU R                    U R                   U R                   S3$ )NÚ(Ú))rÒ   rw   rÓ   r   s    r   r$   ÚFunctionalCategory.__str__e  s%   € Ø�4—9‘9�+˜dŸi™i˜[¨¯©¨°1Ð5Ð5r   )rÓ   r)   rw   rÒ   N)r5   rA   rB   rC   rD   rO   r   r   r   r   r    rÕ   rÔ   rz   r$   rE   r   r   r   rÐ   rÐ   /  s9   † ñò/òòòò
?ò
òòòõ6r   rÐ   N)Úabcr   r   Ú	functoolsr   Únltk.internalsr   r   rH   rt   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   