1
2
3
4
5
6
7
8
9
10
11
12 from nltk_lite.contrib.classifier.exceptions import systemerror as system, invaliddataerror as inv
13 import item
14
17 self.klass_value, self.attrs, self.classified_klass = None, None, None
18
21
22 - def value(self, attribute):
26
32
37
44
46 if other is None: return False
47 if self.__class__ != other.__class__: return False
48 if self.klass_value == other.klass_value and self.attrs == other.attrs and self.classified_klass == other.classified_klass: return True
49 return False
50
53
55 return ' Classified as: ' + self.check_none(self.classified_klass)
56
58 if var is None:
59 return ' '
60 return var.__str__()
61
63 return ' Class: ' + self.check_none(self.klass_value)
64
66 return 'Attributes: ' + self.check_none(self.attrs)
67
69 strn = ''
70 for attr in self.attrs:
71 strn += attr
72 strn += ','
73 return strn[:-1]
74
76 - def __init__(self, attr_values, klass_value):
77 Instance.__init__(self)
78 self.klass_value, self.attrs = klass_value, attr_values
79
82
85
90
92 self.classified_klass = klass
93
96
99
101 - def __init__(self, attr_values, klass_value):
103
106
108 if self.classified_klass == None: raise system.SystemError('Cannot find classification type for instance that has not been classified')
109
112