+
    ÖÇÜh5%  ã                   ó  € R t ^ RIt^ RIHt ^ RIHtHtHtHt ^ RI	H
t
 ^ RIHt ]P                  ! R4      t]P                  ! R4      t]P                  ! R4      t]P                  ! R	]P"                  4      t]P                  ! R
]P"                  4      t]P                  ! R]P"                  4      t]P                  ! R4      t ! R R4      t ! R R4      tR tR tR tR tR tRR ltRR lt]
! R4      R 4       t]! R4      t R# )z
CCG Lexicons
N)Údefaultdict)ÚCCGVarÚ	DirectionÚFunctionalCategoryÚPrimitiveCategory)Ú
deprecated)Ú
Expressionz([A-Za-z]+)(\[[A-Za-z,]+\])?z"([A-Za-z]+(?:\[[A-Za-z,]+\])?)(.*)z([\\/])([.,]?)([.,]?)(.*)z([\S_]+)\s*(::|[-=]+>)\s*(.+)z([^{}]*[^ {}])\s*(\{[^}]+\})?z\{([^}]+)\}z([^#]*)(?:#.*)?c                   óF   a € ] tR t^-t o RtR	R ltR tR tR tR t	Rt
V tR# )
ÚTokenz¨
Class representing a token.

token => category {semantics}
e.g. eat => S\var[pl]/var {\x y.eat(x,y)}

* `token` (string)
* `categ` (string)
* `semantics` (Expression)
Nc                ó*   € Wn         W n        W0n        R # ©N)Ú_tokenÚ_categÚ
_semantics)ÚselfÚtokenÚcategÚ	semanticss   &&&&Ú2/usr/lib/python3/dist-packages/nltk/ccg/lexicon.pyÚ__init__ÚToken.__init__9   s   € ØŒØŒØ#Žó    c                ó   € V P                   # r   )r   ©r   s   &r   r   ÚToken.categ>   s   € Ø�{‰{Ðr   c                ó   € V P                   # r   )r   r   s   &r   r   ÚToken.semanticsA   s   € Ø�‰Ðr   c                ó®   € R pV P                   e$   R\        V P                   4      ,           R,           pR \        V P                  4      ,           V,           # )Ú z {Ú})r   Ústrr   )r   Úsemantics_strs   & r   Ú__str__ÚToken.__str__D   sB   € ØˆØ�?‰?Ò&Ø ¤3 t§¡Ó#7Õ7¸#Õ=ˆMØ”C˜Ÿ™Ó$Õ$ }Õ4Ð4r   c                ó°   € \        V\        4      '       g   R# \        V P                  V P                  3VP                  4       VP                  4       4      # )é   éÿÿÿÿ)Ú
isinstancer
   Úcmpr   r   r   r   )r   Úothers   &&r   Ú__cmp__ÚToken.__cmp__J   s=   € Ü˜%¤×'Ò'ØˆIÜ�D—K‘K §¡Ð1°5·;±;³=À%Ç/Á/ÓBSÓTÐTr   )r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r"   r*   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r
   r
   -   s*   ø‡ € ñ	ô$ò
òò5÷Uð Ur   r
   c                   ó<   a € ] tR t^Pt o RtR tR tR tR tRt	V t
R# )Ú
CCGLexiconzÎ
Class representing a lexicon for CCG grammars.

* `primitives`: The list of primitive categories for the lexicon
* `families`: Families of categories
* `entries`: A mapping of words to possible categories
c                óJ   € \        V4      V n        W n        W0n        W@n        R # r   )r   Ú_startÚ_primitivesÚ	_familiesÚ_entries)r   ÚstartÚ
primitivesÚfamiliesÚentriess   &&&&&r   r   ÚCCGLexicon.__init__Y   s   € Ü'¨Ó.ˆŒØ%ÔØ!ŒØŽr   c                ó(   € V P                   V,          # )z0
Returns all the possible categories for a word
)r;   )r   Úwords   &&r   Ú
categoriesÚCCGLexicon.categories_   s   € ð �}‰}˜TÕ"Ð"r   c                ó   € V P                   # )z+
Return the target category for the parser
)r8   r   s   &r   r<   ÚCCGLexicon.starte   s   € ð �{‰{Ðr   c                ó  € RpRp\        V P                  4       Fc  pV'       g
   VR,           pW,           R,           pRpV P                  V,           F'  pV'       g   VR,           pMRpVRV,          ,           pK)  	  Ke  	  V# )z;
String representation of the lexicon. Used for debugging.
r   TÚ
z => z | Fz%s)Úsortedr;   )r   ÚstringÚfirstÚidentÚcats   &    r   r"   ÚCCGLexicon.__str__k   sz   € ð ˆØˆÜ˜DŸM™MÖ*ˆEßØ $��Ø•^ fÕ,ˆFàˆEØ—}‘} U×+Ð+�ßØ# e�^‘Fà!�EØ $¨¥*Õ,’ó ,ñ +ð ˆr   )r;   r:   r9   r8   N)r,   r-   r.   r/   r0   r   rC   r<   r"   r1   r2   r3   s   @r   r6   r6   P   s#   ø‡ € ñò ò#ò÷ð r   r6   c                óh  € V R,          pRpVR8w  d`   VP                  R4      '       gI   VP                  R4      '       d   \        V4      w  r1W#,           pKL  W!^ ,          ,           pVR,          pKf  VP                  R4      '       d   VR,           VR,          3# \        RV ,           R,           4      h)zV
Separate the contents matching the first set of brackets from the rest of
the input.
ºr%   NNÚ(r   Ú)zUnmatched bracket in string 'Ú')Ú
startswithÚmatchBracketsÚAssertionError)rJ   ÚrestÚinsideÚparts   &   r   rU   rU   …   s–   € ð
 �"�:€DØ€Fà
�"Œ*˜TŸ_™_¨S×1Ò1Ø�?‰?˜3×ÒÜ(¨Ó.‰LˆTØ•]ŠFà 1�gÕ%ˆFØ˜•8ŠDØ‡��s×ÒØ˜•˜d 2�hÐ'Ð'Ü
Ð8¸6ÕAÀCÕGÓ
HÐHr   c                óŒ   € V P                  R4      '       d   \        V 4      # \        P                  V 4      P	                  4       # )zV
Separate the string for the next portion of the category from the rest
of the string
rQ   )rT   rU   ÚNEXTPRIM_REÚmatchÚgroups)rJ   s   &r   ÚnextCategoryr^   ™   s:   € ð
 ×Ñ˜×ÒÜ˜VÓ$Ð$Ü×Ñ˜VÓ$×+Ñ+Ó-Ð-r   c                ó6   € \        V ^ ,          V R,          4      # )z
Parse an application operator
rP   )r   )Úapps   &r   ÚparseApplicationra   £   s   € ô �S˜•V˜S �WÓ%Ð%r   c                ó>   € V '       d   V ^R P                  R4      # . # )z/
Parse the subscripts for a primitive category
Ú,r&   )Úsplit)Úsubscrs   &r   ÚparseSubscriptsrf   ª   s#   € ÷ Ø�a˜ˆ|×!Ñ! #Ó&Ð&Ø€Ir   c                óB  € V ^ ,          R8X  d   V ^,          f   Vf   \        4       pW33# V ^ ,          pWB9   d*   W$,          w  rVVf   TpWS3# VP                  Wc3.4      pWS3# WA9   d    \        V ^,          4      p\        WG4      V3# \	        RV,           R,           4      h)zs
Parse a primitive category

If the primitive is the special category 'var', replace it with the
correct `CCGVar`.
ÚvarzString 'z-' is neither a family nor primitive category.)r   Ú
substituterf   r   rV   )Úchunksr=   r>   rh   ÚcatstrrM   ÚcvarÚsubscrss   &&&&    r   ÚparsePrimitiveCategoryrn   ³   s¶   € ð ˆa…y�EÔØ�!�9ÒØŠ{Ü“h�Ø�:Ðà�A�Y€FØÔØÕ&‰ˆØŠ;ØˆCð ˆzÐð —.‘. 4 + Ó/ˆCØˆzÐàÔÜ! &¨¥)Ó,ˆÜ! &Ó2°CÐ8Ð8Ü
Ø�VÕÐMÕMóð r   c                óJ  € \        V 4      w  rEVP                  R4      '       d   \        V^R WV4      w  rcM0\        \        P                  V4      P                  4       WV4      w  rcVR8w  d´   \        P                  V4      P                  4       p\        VR,          4      pV^,          p\        V4      w  rEVP                  R4      '       d   \        V^R WV4      w  r“M0\        \        P                  V4      P                  4       WV4      w  r“\        WiV4      pKº  Wc3# )zo
Parse a string representing a category, and returns a tuple with
(possibly) the CCG variable for the category
rQ   r   :é    é   Nr&   )
r^   rT   ÚaugParseCategoryrn   ÚPRIM_REr\   r]   ÚAPP_REra   r   )
Úliner=   r>   rh   Ú
cat_stringrW   Úresr`   Ú	directionÚargs
   &&&&      r   rr   rr   Ñ   s  € ô
 & dÓ+Ñ€Zà×Ñ˜S×!Ò!Ü% j°°2Ð&6¸
ÈcÓR‰
ˆˆcô ,Ü�M‰M˜*Ó%×,Ñ,Ó.°
Àcó
‰
ˆð �"Œ*Ü�l‰l˜4Ó ×'Ñ'Ó)ˆÜ$ S¨¥XÓ.ˆ	Ø�1�vˆä)¨$Ó/ÑˆØ× Ñ  ×%Ò%Ü)¨*°Q°rÐ*:¸JÐRUÓV‰JˆS�#ä/Ü—‘˜jÓ)×0Ñ0Ó2°JÈ#ó‰JˆSô ! ¨9Ó5Šàˆ:Ðr   c                óÈ  € \         P                  ! 4        . p/ p\        \        4      pV P	                  4        EF�  p\
        P                  V4      P                  4       ^ ,          P                  4       pVR8X  d   KE  VP                  R4      '       dM   TVR,          P                  4       P                  R4       Uu. uF  qfP                  4       NK  	  up,           pK¨  \        P                  V4      P                  4       w  rxp	\        P                  V	4      P                  4       w  r«\        W¢V4      w  rÍVR8X  d	   WÍ3W7&   EK  RpVRJ dU   Vf   \        VR,           4      h\        P                   ! \"        P                  V4      P                  4       ^ ,          4      pWG,          P%                  \'        W|V4      4       EK�  	  \)        V^ ,          W#V4      # u upi )	z8
Convert string representation into a lexicon for CCGs.
r   z:-:é   NNrc   z::NTz@ must contain semantics because include_semantics is set to True)r   Úreset_idr   ÚlistÚ
splitlinesÚCOMMENTS_REr\   r]   ÚstriprT   rd   ÚLEX_REÚRHS_RErr   rV   r   Ú
fromstringÚSEMANTICS_REÚappendr
   r6   )Úlex_strÚinclude_semanticsr=   r>   r?   ru   ÚprimrL   ÚsepÚrhsrk   r!   rM   rh   r   s   &&             r   rƒ   rƒ   ñ   sš  € ô ‡O‚OÔØ€JØ€HÜœ$Ó€GØ×"Ñ"×$ˆä× Ñ  Ó&×-Ñ-Ó/°Õ2×8Ñ8Ó:ˆØ�2Œ:Ùà�?‰?˜4× Ò ð $Ø)-¨b­¯©Ó)9×)?Ñ)?ÀÔ)Dó'Ù)D —
‘
–Ñ)Dñ'õ ŠJô
 !'§¡¨TÓ 2× 9Ñ 9Ó ;ÑˆU˜Ü&,§l¡l°3Ó&7×&>Ñ&>Ó&@Ñ#ˆVÜ)¨&¸hÓG‰JˆSà�dŒ{ð $' *�”à �	Ø$¨Ó,Ø$Ò,Ü,Ø Ø`õaóð ô
 %/×$9Ò$9Ü(×.Ñ.¨}Ó=×DÑDÓFÀqÕIó%˜	ð
 •×%Ñ%¤e¨E¸	Ó&B×CñK %ôL �j •m Z¸7ÓCÐCùò9's   Â>GzUse fromstring() instead.c                 ó   € \        V 4      # r   )rƒ   )r†   s   &r   ÚparseLexiconrŒ   "  s   € ä�gÓÐr   a¡  
    # Rather minimal lexicon based on the openccg `tinytiny' grammar.
    # Only incorporates a subset of the morphological subcategories, however.
    :- S,NP,N                    # Primitive categories
    Det :: NP/N                  # Determiners
    Pro :: NP
    IntransVsg :: S\NP[sg]    # Tensed intransitive verbs (singular)
    IntransVpl :: S\NP[pl]    # Plural
    TransVsg :: S\NP[sg]/NP   # Tensed transitive verbs (singular)
    TransVpl :: S\NP[pl]/NP   # Plural

    the => NP[sg]/N[sg]
    the => NP[pl]/N[pl]

    I => Pro
    me => Pro
    we => Pro
    us => Pro

    book => N[sg]
    books => N[pl]

    peach => N[sg]
    peaches => N[pl]

    policeman => N[sg]
    policemen => N[pl]

    boy => N[sg]
    boys => N[pl]

    sleep => IntransVsg
    sleep => IntransVpl

    eat => IntransVpl
    eat => TransVpl
    eats => IntransVsg
    eats => TransVsg

    see => TransVpl
    sees => TransVsg
    r   )F)!r0   ÚreÚcollectionsr   Únltk.ccg.apir   r   r   r   Únltk.internalsr   Únltk.sem.logicr   Úcompilers   r[   rt   ÚUNICODEr�   r‚   r„   r   r
   r6   rU   r^   ra   rf   rn   rr   rƒ   rŒ   Úopenccg_tinytiny© r   r   Ú<module>r–      s  ðñó 
Ý #ç QÓ QÝ %Ý %ð �*Š*Ð8Ó
9€ð �jŠjÐBÓC€ð 
�ŠÐ4Ó	5€ð 
�ŠÐ8¸"¿*¹*Ó	E€ð 
�ŠÐ8¸"¿*¹*Ó	E€ð �zŠzÐ,¨b¯j©jÓ9€ð �jŠjÐ.Ó/€÷ Uñ  U÷F-ñ -òjIò(.ò&òòô<ô@.Dñb Ð'Ó(ñó )ðñ ð)ó+Ò r   