-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.py
64 lines (56 loc) · 2.53 KB
/
model.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class Property(object):
"""A database record meaning someone some property"""
def __init__(self, who, what_property):
super(Property, self).__init__()
self.who = who
self.what_property = what_property
def __str__(self):
return "Property<" + self.who + " : " + self.what_property + ">"
class QuantifiedProperty(Property):
"""A database record meaning someone some property with a value"""
def __init__(self, who, what_property, how_much, units):
super().__init__(who, what_property)
self.how_much = how_much
self.units = units
def __str__(self):
return "QuantifiedProperty<" + self.who + " : " + self.what_property + " (" + str(self.how_much) + " " + self.units + ")>"
class QualifiedProperty(Property):
"""A database record meaning someone some property with a value"""
def __init__(self, who, what_property, how):
super().__init__(who, what_property)
self.how = how
def __str__(self):
return "QualifiedProperty<" + self.who + " : " + self.what_property + "(" + self.how + ")>"
class QualifiedRelation(object):
"""A database record meaning someone a relation to someone else"""
def __init__(self, who, what_relation, what_entity, qualifications):
super(QualifiedRelation, self).__init__()
self.who = who
self.what_relation = what_relation
self.qualifications = qualifications
self.what_entity = what_entity
def __str__(self):
str = "QualifiedRelation<" + self.who + " : " + self.what_relation + " : " + self.what_entity
if len(self.qualifications) > 0:
str += "(" + ", ".join(self.qualifications) + ")"
str += ">"
return str
class SpecifiedRelation:
"""A database record meaning someone a relation to something"""
def __init__(self, who, verb, what):
super(SpecifiedRelation, self).__init__()
self.who = who
self.verb = verb
self.what = what
def __str__(self):
return "SpecifiedRelation<" + self.who + " : " + self.verb + " : " + self.what + ">"
class QuantifiedRelation:
"""A database record meaning someone a relation to multiple entities"""
def __init__(self, who, what_relation, num, whom):
super(QuantifiedRelation, self).__init__()
self.who = who
self.what_relation = what_relation
self.num = num
self.whom = whom
def __str__(self):
return "QuantifiedRelation<" + self.who + " : " + self.what_relation + " " + self.num + " " + self.whom + ">"