models.py
2.93 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from django.db import models
from meanings.models import LexicalUnit, Synset
class Frame(models.Model):
lexical_units = models.ManyToManyField(LexicalUnit, related_name='frames')
opinion = models.ForeignKey('FrameOpinion', on_delete=models.PROTECT)
arguments_count = models.PositiveIntegerField(null=False, default=0)
def sorted_arguments(self): # TODO: zaimplementowac wlasciwe sortowanie
return Argument.objects.filter(frame=self)
def __str__(self):
return '%s: %s' % (self.opinion, ' + '.join([str(arg) for arg in self.sorted_arguments()]))
class FrameOpinion(models.Model):
key = models.CharField(max_length=16, unique=True)
# name = TODO wymaga lokalizacji
priority = models.PositiveIntegerField()
class Meta:
ordering = ['priority']
def __str__(self):
return self.key
class Argument(models.Model):
role = models.ForeignKey('ArgumentRole', on_delete=models.PROTECT)
predefined = models.ManyToManyField('PredefinedSelectionalPreference')
synsets = models.ManyToManyField(Synset)
relations = models.ManyToManyField('RelationalSelectionalPreference')
frame = models.ForeignKey(Frame, on_delete=models.PROTECT)
preferences_count = models.PositiveIntegerField(null=False, default=0)
def __str__(self):
return str(self.role)
class ArgumentRole(models.Model):
role = models.ForeignKey('SemanticRole', on_delete=models.PROTECT)
attribute = models.ForeignKey('RoleAttribute', null=True, on_delete=models.PROTECT)
def __str__(self):
if self.attribute is None:
return str(self.role)
else:
return str(self.role) + " " + str(self.attribute)
class SemanticRole(models.Model):
role = models.CharField(max_length=20)
color = models.CharField(max_length=11, null=True)
priority = models.PositiveIntegerField()
class Meta:
ordering = ['priority']
def __str__(self):
return self.role
class RoleAttribute(models.Model):
attribute = models.CharField(max_length=20)
gradient = models.CharField(max_length=10, null=True)
priority = models.PositiveIntegerField()
class Meta:
ordering = ['priority']
def __str__(self):
return self.attribute
class PredefinedSelectionalPreference(models.Model):
key = models.CharField(max_length=20, unique=True)
# name = TODO: wymaga lokalizacji
def __str__(self):
return self.key
class RelationalSelectionalPreference(models.Model):
relation = models.ForeignKey('SelectionalPreferenceRelation', on_delete=models.PROTECT)
to = models.ForeignKey('Argument', on_delete=models.PROTECT)
def __str__(self):
return '%s -> %s' % (self.relation, self.to)
class SelectionalPreferenceRelation(models.Model):
key = models.CharField(max_length=40, unique=True)
# name = TODO: wymaga lokalizacji
plwn_id = models.IntegerField(null=True)
def __str__(self):
return self.key