nltk.cluster.api module

class nltk.cluster.api.ClusterI[source]

Bases: object

Interface covering basic clustering functionality.

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.

abstract classify(token)[source]

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

likelihood(vector, label)[source]

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


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

abstract num_clusters()[source]

Returns the number of clusters.


Returns the names of the clusters. :rtype: list


Returns the names of the cluster at index.