nltk.cluster.api module

class nltk.cluster.api.ClusterI[source]

Bases: object

Interface covering basic clustering functionality.


Classifies the token into a cluster, returning a probability distribution over the cluster identifiers.

abstract classify(token)[source]

Classifies the token into a cluster, setting the token’s CLUSTER parameter to that cluster identifier.

abstract cluster(vectors, assign_clusters=False)[source]

Assigns the vectors to clusters, learning the clustering parameters from the data. Returns a cluster identifier for each vector.


Returns the names of the cluster at index.


Returns the names of the clusters. :rtype: list

likelihood(vector, label)[source]

Returns the likelihood (a float) of the token having the corresponding cluster.

abstract num_clusters()[source]

Returns the number of clusters.