2016-10-22 12:43:52 +00:00
|
|
|
class _BaseCriterion:
|
2016-06-03 10:13:43 +00:00
|
|
|
def __init__(self, original_text):
|
2016-04-02 12:40:10 +00:00
|
|
|
self.original_text = original_text
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return self.original_text
|
|
|
|
|
2016-08-14 12:22:53 +00:00
|
|
|
|
2016-06-03 10:13:43 +00:00
|
|
|
class RangedCriterion(_BaseCriterion):
|
|
|
|
def __init__(self, original_text, min_value, max_value):
|
|
|
|
super().__init__(original_text)
|
2016-04-02 12:40:10 +00:00
|
|
|
self.min_value = min_value
|
|
|
|
self.max_value = max_value
|
|
|
|
|
2016-06-03 11:50:38 +00:00
|
|
|
def __hash__(self):
|
|
|
|
return hash(('range', self.min_value, self.max_value))
|
|
|
|
|
2016-08-14 12:22:53 +00:00
|
|
|
|
2016-06-03 10:13:43 +00:00
|
|
|
class PlainCriterion(_BaseCriterion):
|
|
|
|
def __init__(self, original_text, value):
|
|
|
|
super().__init__(original_text)
|
2016-04-02 12:40:10 +00:00
|
|
|
self.value = value
|
|
|
|
|
2016-06-03 11:50:38 +00:00
|
|
|
def __hash__(self):
|
|
|
|
return hash(self.value)
|
|
|
|
|
2016-08-14 12:22:53 +00:00
|
|
|
|
2016-06-03 10:13:43 +00:00
|
|
|
class ArrayCriterion(_BaseCriterion):
|
|
|
|
def __init__(self, original_text, values):
|
|
|
|
super().__init__(original_text)
|
2016-04-02 12:40:10 +00:00
|
|
|
self.values = values
|
2016-06-03 11:50:38 +00:00
|
|
|
|
|
|
|
def __hash__(self):
|
|
|
|
return hash(tuple(['array'] + self.values))
|