1
2
3
4
5
6
7
8
9 from nltk import DictionaryProbDist
10
12 """
13 Interface covering basic clustering functionality.
14 """
15
16 - def cluster(self, vectors, assign_clusters=False):
17 """
18 Assigns the vectors to clusters, learning the clustering parameters
19 from the data. Returns a cluster identifier for each vector.
20 """
21 raise AssertionError()
22
24 """
25 Classifies the token into a cluster, setting the token's CLUSTER
26 parameter to that cluster identifier.
27 """
28 raise AssertionError()
29
31 """
32 Returns the likelihood (a float) of the token having the
33 corresponding cluster.
34 """
35 if self.classify(vector) == label:
36 return 1.0
37 else:
38 return 0.0
39
53
55 """
56 Returns the number of clusters.
57 """
58 raise AssertError()
59
61 """
62 Returns the names of the clusters.
63 """
64 return range(self.num_clusters())
65
67 """
68 Returns the names of the cluster at index.
69 """
70 return index
71