3
dr                 @   s2   d dl mZmZ d dlmZ G dd dedZdS )    )ABCMetaabstractmethod)DictionaryProbDistc               @   sV   e Zd ZdZedddZedd Zdd Zd	d
 Zedd Z	dd Z
dd ZdS )ClusterIz<
    Interface covering basic clustering functionality.
    Fc             C   s   dS )z
        Assigns the vectors to clusters, learning the clustering parameters
        from the data. Returns a cluster identifier for each vector.
        N )selfZvectorsZassign_clustersr   r   0/tmp/pip-build-v9q4h5k9/nltk/nltk/cluster/api.pycluster   s    zClusterI.clusterc             C   s   dS )z
        Classifies the token into a cluster, setting the token's CLUSTER
        parameter to that cluster identifier.
        Nr   )r   tokenr   r   r   classify   s    zClusterI.classifyc             C   s   | j ||krdS dS dS )zi
        Returns the likelihood (a float) of the token having the
        corresponding cluster.
        g      ?g        N)r   )r   vectorlabelr   r   r   
likelihood!   s    zClusterI.likelihoodc             C   s`   i }d}x,| j  D ] }| j||||< ||| 7 }qW x | j  D ]}||  |  < q@W t|S )z
        Classifies the token into a cluster, returning
        a probability distribution over the cluster identifiers.
        g        )cluster_namesr   r   )r   r   Zlikelihoodssumr	   r   r   r   classification_probdist+   s    z ClusterI.classification_probdistc             C   s   dS )z1
        Returns the number of clusters.
        Nr   )r   r   r   r   num_clusters9   s    zClusterI.num_clustersc             C   s   t t| j S )zI
        Returns the names of the clusters.
        :rtype: list
        )listranger   )r   r   r   r   r   ?   s    zClusterI.cluster_namesc             C   s   |S )z<
        Returns the names of the cluster at index.
        r   )r   indexr   r   r   cluster_nameF   s    zClusterI.cluster_nameN)F)__name__
__module____qualname____doc__r   r	   r   r   r   r   r   r   r   r   r   r   r      s   
r   )	metaclassN)abcr   r   Znltk.probabilityr   r   r   r   r   r   <module>	   s   