models.py
2.46 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
from django.db import models
from meanings.models import LexicalUnit, Synset
class Frame(models.Model): # TODO: jak wspoldzielic ramy?
entry = models.ForeignKey('connections.Entry', related_name='frames', on_delete=models.PROTECT)
lexical_units = models.ManyToManyField(LexicalUnit, related_name='frames')
arguments = models.ManyToManyField('Argument')
opinion = models.ForeignKey('FrameOpinion', on_delete=models.PROTECT)
def sorted_arguments(self): # TODO: zaimplementowac wlasciwe sortowanie
return self.arguments.all()
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):
roles = models.ManyToManyField('SemanticRole')
selective_preference = models.ForeignKey('SelectivePreference', on_delete=models.PROTECT)
def __str__(self):
return str(self.roles.all())
class SemanticRole(models.Model):
role = models.CharField(max_length=20)
color = models.CharField(max_length=11)
gradient = models.CharField(max_length=10)
priority = models.PositiveIntegerField()
class Meta:
ordering = ['priority']
def __str__(self):
return self.role
class SelectivePreference(models.Model):
generals = models.ManyToManyField('GeneralSelectivePreference')
synsets = models.ManyToManyField(Synset)
relations = models.ManyToManyField('RelationalSelectivePreference')
class GeneralSelectivePreference(models.Model):
key = models.CharField(max_length=20, unique=True)
# name = TODO: wymaga lokalizacji
members = models.ForeignKey('SelectivePreference', on_delete=models.PROTECT)
def __str__(self):
return self.key
class RelationalSelectivePreference(models.Model):
relation = models.ForeignKey('SelectivePreferenceRelation', on_delete=models.PROTECT)
to = models.ForeignKey('Argument', on_delete=models.PROTECT)
def __str__(self):
return '%s -> %s' % (self.relation, self.to)
class SelectivePreferenceRelation(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