models.py
4.99 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
from django.db import models
class Subentry(models.Model):
entry = models.ForeignKey('connections.Entry', related_name='subentries', on_delete=models.PROTECT)
aspect = models.ForeignKey('Aspect', related_name='subentries', on_delete=models.PROTECT)
inherent_sie = models.ForeignKey('InherentSie', related_name='subentries', on_delete=models.PROTECT)
negativity = models.ForeignKey('Negativity', related_name='subentries', on_delete=models.PROTECT)
predicativity = models.ForeignKey('Predicativity', related_name='subentries', on_delete=models.PROTECT)
schemata = models.ManyToManyField('Schema', related_name='subentries')
def __str__(self):
if self.inherent_sie is None:
return '%s (%s,%s,%s)' % (self.entry.name, self.negativity, self.predicativity, self.aspect)
return '%s %s (%s,%s,%s)' % (self.entry.name, self.inherent_sie, self.negativity, self.predicativity,
self.aspect)
class Aspect(models.Model):
name = models.CharField(max_length=16, unique=True)
priority = models.PositiveIntegerField()
class Meta:
ordering = ['priority']
def __str__(self):
return self.name
class InherentSie(models.Model):
name = models.CharField(max_length=16, unique=True)
priority = models.PositiveIntegerField()
class Meta:
ordering = ['priority']
def __str__(self):
return self.name
class Negativity(models.Model):
name = models.CharField(max_length=16, unique=True)
priority = models.PositiveIntegerField()
class Meta:
ordering = ['priority']
def __str__(self):
return self.name
class Predicativity(models.Model):
name = models.CharField(max_length=16, unique=True)
priority = models.PositiveIntegerField()
class Meta:
ordering = ['priority']
def __str__(self):
return self.name
class Schema(models.Model):
opinion = models.ForeignKey('SchemaOpinion', related_name='schemata', on_delete=models.PROTECT)
phraseologic = models.BooleanField()
positions = models.ManyToManyField('Position', related_name='schemata')
def sorted_positions(self): # TODO: zaimplementowac wlasciwe sortowanie
return self.positions.all()
def __str__(self):
return '%s: %s' % (self.opinion, ' + '.join([str(pos) for pos in self.sorted_positions()]))
class SchemaOpinion(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 Position(models.Model):
function = models.ForeignKey('SyntacticFunction', related_name='positions', on_delete=models.PROTECT)
control = models.ForeignKey('Control', related_name='positions', on_delete=models.PROTECT)
pred_control = models.ForeignKey('PredicativeControl', related_name='positions', on_delete=models.PROTECT)
phrase_types = models.ManyToManyField('PhraseType', related_name='positions')
def sorted_phrase_types(self): # TODO: zaimplementowac wlasciwe sortowanie
return self.phrase_types.all()
def __str__(self):
categories = []
if self.function is not None:
categories.append(str(self.function))
if self.control is not None:
categories.append(str(self.control))
if self.pred_control is not None:
categories.append(str(self.pred_control))
return '%s{%s}' % (','.join(categories), ';'.join([str(pt) for pt in self.sorted_phrase_types()]))
class SyntacticFunction(models.Model):
name = models.CharField(max_length=16, unique=True)
priority = models.PositiveIntegerField()
class Meta:
ordering = ['priority']
def __str__(self):
return self.name
class Control(models.Model):
name = models.CharField(max_length=16, unique=True)
priority = models.PositiveIntegerField()
class Meta:
ordering = ['priority']
def __str__(self):
return self.name
class PredicativeControl(models.Model):
name = models.CharField(max_length=16, unique=True)
priority = models.PositiveIntegerField()
class Meta:
ordering = ['priority']
def __str__(self):
return self.name
class PhraseType(models.Model):
main_type = models.ForeignKey('PhraseTypeModel', related_name='main_phrase_types', on_delete=models.PROTECT)
lexicalized_phrase = models.ForeignKey('PhraseType', related_name='lex_phrases', on_delete=models.PROTECT)
text_rep = models.TextField(unique=True)
# realizations = TODO: uwzglednic jakos realizacje typow fraz
class Meta:
ordering = ['main_type__priority']
def __str__(self):
return self.text_rep
class PhraseTypeModel(models.Model):
name = models.CharField(max_length=16, unique=True)
phraseologic = models.BooleanField()
priority = models.PositiveIntegerField()
class Meta:
ordering = ['priority']
def __str__(self):
return self.name