³ò
ŒB_Kc           @   so   d  e  f d „  ƒ  YZ d e f d „  ƒ  YZ d d d „  ƒ  YZ d e f d „  ƒ  YZ d e f d	 „  ƒ  YZ d
 S(   t   AbstractCCGCategoryc           B   sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   s;   
    Interface for categories in combinatory grammars.
    c         C   s   t  d ‚ d  S(   Ns,   AbstractCCGCategory is an abstract interface(   t   AssertionError(   t   self(    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt   is_primitive   s    c         C   s   t  d ‚ d  S(   Ns,   AbstractCCGCategory is an abstract interface(   R   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt   is_function   s    c         C   s   t  d ‚ d  S(   Ns,   AbstractCCGCategory is an abstract interface(   R   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt   is_var   s    c         C   s   t  d ‚ d  S(   Ns,   AbstractCCGCategory is an abstract interface(   R   (   R   t   substitutions(    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt
   substitute   s    c         C   s   t  d ‚ d  S(   Ns,   AbstractCCGCategory is an abstract interface(   R   (   R   t   other(    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt	   can_unify!   s    c         C   s   t  d ‚ d  S(   Ns,   AbstractCCGCategory is an abstract interface(   R   (   R   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt   __cmp__%   s    c         C   s   t  d ‚ d  S(   Ns,   AbstractCCGCategory is an abstract interface(   R   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt   __str__(   s    c         C   s   t  d ‚ d  S(   Ns,   AbstractCCGCategory is an abstract interface(   R   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt   __hash__+   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R	   R
   R   R   (    (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR       s   							t   CCGVarc           B   s†   e  Z d  Z d Z e d „ Z d „  Z e e ƒ Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z RS(   s   
    Class representing a variable CCG category.
    Used for conjunctions (and possibly type-raising, if implemented as a
    unary rule).
    i    c         C   s   |  i  ƒ  |  _ | |  _ d S(   sÄ   Initialize a variable (selects a new identifier)

        @param prim_only: a boolean that determines whether the variable is restricted to primitives 
        @type prim_only: C{boolean}
        N(   t   new_idt   _idt
   _prim_only(   R   t	   prim_only(    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt   __init__7   s    c         C   s   |  i  d |  _  |  i  d S(   Ni   (   t   _maxID(   t   cls(    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   A   s    c         C   s   t  S(   N(   t   False(   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   F   s    c         C   s   t  S(   N(   R   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   I   s    c         C   s   t  S(   N(   t   True(   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   L   s    c         C   s0   x) | D]! \ } } | |  j o | Sq q W|  S(   sl   If there is a substitution corresponding to this variable,
        return the substituted category.
        (    (   R   R   t   vart   cat(    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   O   s
     c         C   s-   | i  ƒ  p |  i o |  | f g Sn t S(   sX    If the variable can be replaced with other
        a substitution is returned.
        (   R   R   t   None(   R   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR	   X   s    c         C   s   |  i  S(   N(   R   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt   id`   s    c         C   s.   t  | t ƒ p d Sn t |  i | i ƒ  ƒ S(   Niÿÿÿÿ(   t
   isinstanceR   t   cmpR   R   (   R   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR
   c   s    c         C   s   t  |  i ƒ S(   N(   t   hashR   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   h   s    c         C   s   d t  |  i ƒ S(   Nt   _var(   t   strR   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   j   s    (   R   R   R   R   R   R   R   t   classmethodR   R   R   R   R	   R   R
   R   R   (    (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   /   s   
										t	   Directionc           B   sŒ   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 RS(   s¨   
    Class representing the direction of a function application.
    Also contains maintains information as to which combinators
    may be used with the category.
    c         C   s   | |  _  | |  _ d  S(   N(   t   _dirt   _restrs(   R   t   dirt   restrictions(    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   s   s    	c         C   s   |  i  d j S(   Nt   /(   R%   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt
   is_forwardx   s    c         C   s   |  i  d j S(   Ns   \(   R%   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt   is_backwardz   s    c         C   s   |  i  S(   N(   R%   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR'   }   s    c         C   s   |  i  S(   s8  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"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt   restrs€   s    c         C   s   |  i  d j S(   Nt   _(   R&   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt   is_variable‰   s    c         C   sm   | i  ƒ  o d |  i ƒ  f g SnF |  i  ƒ  o d | i ƒ  f g Sn" |  i ƒ  | i ƒ  j o g  Sn d  S(   NR-   (   R.   R,   R   (   R   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR	      s    c         C   sQ   |  i  ƒ  p |  Sn x5 | D]- \ } } | d j o t |  i | ƒ Sq q W|  S(   NR-   (   R.   R$   R%   (   R   t   subsR   R,   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   ™   s     c         C   s   d |  i  j S(   Nt   ,(   R&   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt   can_compose£   s    c         C   s   d |  i  j S(   Nt   .(   R&   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt	   can_cross¦   s    c         C   s+   t  |  i |  i f | i ƒ  | i ƒ  f ƒ S(   N(   R   R%   R&   R'   R,   t   res(   R   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR
   ©   s    +c         C   s   t  |  i t |  i ƒ f ƒ S(   N(   R    R%   t   tupleR&   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   ­   s    c         C   s;   d } x! |  i  D] } | t | ƒ } q Wt |  i ƒ | S(   Nt    (   R&   R"   R%   (   R   t   r_strt   r(    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   °   s
    
 c         C   s8   |  i  d j o t d |  i ƒ Sn t d |  i ƒ Sd  S(   NR)   s   \(   R%   R$   R&   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyt   __neg__·   s    (   R   R   R   R   R*   R+   R'   R,   R.   R	   R   R1   R3   R
   R   R   R9   (    (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR$   m   s   								
	
					t   PrimitiveCategoryc           B   st   e  Z d  Z g  d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z RS(   s«   
    Class representing primitive categories.
    Takes a string representation of the category, and a
    list of strings specifying the morphological subcategories.
    c         C   s   | |  _  | |  _ d  S(   N(   t   _categR&   (   R   t   categR(   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   Ä   s    	c         C   s   t  S(   N(   R   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   È   s    c         C   s   t  S(   N(   R   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   Ë   s    c         C   s   t  S(   N(   R   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   Î   s    c         C   s   |  i  S(   N(   R&   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR,   Ñ   s    c         C   s   |  i  S(   N(   R;   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR<   Ô   s    c         C   s   |  S(   N(    (   R   R/   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   Ø   s    c         C   s‡   | i  ƒ  p d  Sn | i ƒ  o | |  f g Sn | i ƒ  |  i ƒ  j o7 x, |  i D]! } | | i ƒ  j o d  SqV qV Wg  Sn d  S(   N(   R   R   R   R<   R&   R,   (   R   R   t   restr(    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR	   Þ   s    
 c         C   sF   t  | t ƒ p d Sn t |  i |  i ƒ  f | i ƒ  | i ƒ  f ƒ S(   Niÿÿÿÿ(   R   R:   R   R;   R,   R<   (   R   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR
   ê   s    c         C   s   t  |  i t |  i ƒ f ƒ S(   N(   R    R;   R5   R&   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   ð   s    c         C   s;   |  i  g  j o t |  i ƒ Sn t |  i ƒ t |  i  ƒ S(   N(   R&   R"   R;   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   ó   s    (   R   R   R   R   R   R   R   R,   R<   R   R	   R
   R   R   (    (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR:   ¾   s   									t   FunctionalCategoryc           B   sz   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 RS(   sœ   
    Class that represents a function application category.
    Consists of argument and result categories, together with
    an application direction.
    c         C   s   | |  _  | |  _ | |  _ d  S(   N(   t   _rest   _argR%   (   R   R4   t   argR'   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   þ   s    		c         C   s   t  S(   N(   R   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR     s    c         C   s   t  S(   N(   R   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR     s    c         C   s   t  S(   N(   R   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   	  s    c         C   sI   |  i  i | ƒ } |  i i | ƒ } |  i i | ƒ } t | | |  i ƒ S(   N(   R?   R   R%   R@   R>   (   R   R/   t   sub_rest   sub_dirt   sub_arg(    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR     s    c         C   sÄ   | i  ƒ  o | |  f g Sn | i ƒ  o• |  i i | i ƒ  ƒ } |  i i | i ƒ  ƒ } | d  j oT | d  j oG |  i i	 | ƒ i | i
 ƒ  i	 | ƒ ƒ } | d  j o | | Sq¼ qÀ n d  S(   N(   R   R   R?   R	   R4   R%   R'   R   R@   R   RA   (   R   R   t   sat   sdt   sb(    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR	     s    *c         C   s   |  i  S(   N(   R@   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyRA   #  s    c         C   s   |  i  S(   N(   R?   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR4   &  s    c         C   s   |  i  S(   N(   R%   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR'   )  s    c         C   sR   t  | t ƒ p d Sn t |  i |  i |  i f | i ƒ  | i ƒ  | i ƒ  f ƒ S(   Niÿÿÿÿ(	   R   R>   R   R@   R%   R?   RA   R'   R4   (   R   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR
   ,  s    c         C   s   t  |  i |  i |  i f ƒ S(   N(   R    R@   R%   R?   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   1  s    c         C   s/   d t  |  i ƒ t  |  i ƒ t  |  i ƒ d S(   Nt   (t   )(   R"   R?   R%   R@   (   R   (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR   4  s    (   R   R   R   R   R   R   R   R   R	   RA   R4   R'   R
   R   R   (    (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pyR>   ø   s   											N(    (   t   objectR    R   R$   R:   R>   (    (    (    s"   /p/zhu/06/nlp/nltk/nltk/ccg/api.pys   <module>   s   '>Q: