-
Notifications
You must be signed in to change notification settings - Fork 17
/
predicate.py
47 lines (32 loc) · 1.16 KB
/
predicate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
__author__ = ''
class Predicate(object):
"""
Fuzzy Predicate is represented as 'variable is adjective'
:variable: fuzzy variable
:adjective: fuzzy adjective
"""
__slots__ = ('adjective', 'variable')
def __init__(self, variable, adjective):
"""
Initialize predicate
:param variable: fuzzython.variable
:param adjective: fuzzython.adjective
"""
self.adjective = adjective
self.variable = variable
#self._weight = weight
def evaluate(self):
"""
Gets a value of how much apply the adjective to variable
"""
return self.adjective.membership(self.variable.value)
def change_predicate(self, norm, value):
adjective = self.adjective._adjective_(norm, value)
return Predicate(self.variable, adjective)
def __contains__(self, item):
return item == self.variable or item == self.adjective
def __iter__(self):
yield from (self.variable, self.adjective)
def __repr__(self):
return '{0} IS {1}'.format(self.variable, self.adjective)
__str__ = __repr__