1
2
3
4
5
6
7
8
9
10 """
11 """
12
13 from operator import itemgetter
14
16
17 - def train(self, gold_standard):
18 """
19 @param gold_standard: maps class name to representative samples
20 @ret: nothing if successful
21 """
22 raise NotImplementedError()
23
25 """
26 @param tokens: sample to be classified
27 @ret: only the most probable class name
28 """
29 raise NotImplementedError()
30
32 """
33 @param tokens: sample to be classified
34 @ret: a list of all classes in order of most likely to least likely class
35 """
36 raise NotImplementedError()
37
39 """
40 @param tokens: sample to be classified
41 @ret: DictionaryProbDist of class name and probability
42 see nltk_lite.probability.py
43 """
44 raise NotImplementedError()
45
47 """
48 @param tokens: sample to be classified
49 @ret: dictionary of class names to probability
50 """
51 raise NotImplementedError()
52
53
54
56
58 """
59 @ret: the set of known classes
60 """
61 return self._classes
62
64 """
65 @param text: sample to be classified
66 @ret: most probable class
67 """
68 (cls, prob) = self.get_class_tuples(text)[0]
69 return cls
70
72 """
73 @param text: sample to be classified
74 @ret: ordered list of classification results
75 """
76 tuplelist = self.get_class_tuples(text)
77 return [cls for (cls,prob) in tuplelist]
78
80 """
81 @param text: sample to be classified
82 @ret: an ordered list of tuples
83 """
84 tmp = self.get_class_dict(text)
85 return sorted([(cls, tmp[cls]) for cls in tmp],
86 key=itemgetter(1), reverse=True)
87
96
97
98
99
100
101
102
103
111
112
113 from cosine import *
114 from naivebayes import *
115 from spearman import *
116