³ò
ŒB_Kc           @   s*   d  d k  l Z d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   DictionaryProbDistt   ClusterIc           B   sP   e  Z d  Z e d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(   s<   
    Interface covering basic clustering functionality.
    c         C   s   t  ƒ  ‚ d S(   sš   
        Assigns the vectors to clusters, learning the clustering parameters
        from the data. Returns a cluster identifier for each vector.
        N(   t   AssertionError(   t   selft   vectorst   assign_clusters(    (    s&   /p/zhu/06/nlp/nltk/nltk/cluster/api.pyt   cluster   s    c         C   s   t  ƒ  ‚ d S(   s€   
        Classifies the token into a cluster, setting the token's CLUSTER
        parameter to that cluster identifier.
        N(   R   (   R   t   token(    (    s&   /p/zhu/06/nlp/nltk/nltk/cluster/api.pyt   classify   s    c         C   s&   |  i  | ƒ | j o d Sn d Sd S(   si   
        Returns the likelihood (a float) of the token having the
        corresponding cluster.
        g      ð?g        N(   R   (   R   t   vectort   label(    (    s&   /p/zhu/06/nlp/nltk/nltk/cluster/api.pyt
   likelihood   s    c         C   sx   h  } d } x8 |  i  ƒ  D]* } |  i | | ƒ | | <| | | 7} q Wx$ |  i  ƒ  D] } | | c | :<qT Wt | ƒ S(   s   
        Classifies the token into a cluster, returning
        a probability distribution over the cluster identifiers.
        g        (   t   cluster_namesR   R    (   R   R	   t   likelihoodst   sumR   (    (    s&   /p/zhu/06/nlp/nltk/nltk/cluster/api.pyt   classification_probdist(   s      c         C   s   t  ƒ  ‚ d S(   s1   
        Returns the number of clusters.
        N(   t   AssertError(   R   (    (    s&   /p/zhu/06/nlp/nltk/nltk/cluster/api.pyt   num_clusters6   s    c         C   s   t  |  i ƒ  ƒ S(   s4   
        Returns the names of the clusters.
        (   t   rangeR   (   R   (    (    s&   /p/zhu/06/nlp/nltk/nltk/cluster/api.pyR   <   s    c         C   s   | S(   s<   
        Returns the names of the cluster at index.
        (    (   R   t   index(    (    s&   /p/zhu/06/nlp/nltk/nltk/cluster/api.pyt   cluster_nameB   s    (   t   __name__t
   __module__t   __doc__t   FalseR   R   R   R   R   R   R   (    (    (    s&   /p/zhu/06/nlp/nltk/nltk/cluster/api.pyR      s   		
			N(   t   nltk.probabilityR    t   objectR   (    (    (    s&   /p/zhu/06/nlp/nltk/nltk/cluster/api.pys   <module>	   s   