models.py
2.79 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
from django.db import models
from examples.models import Example
from meanings.models import LexicalUnit
from semantics.models import Argument
from syntax.models import Position, Schema, Subentry
from syntax.models_phrase import PhraseType
class Entry(models.Model):
name = models.CharField(max_length=32)
pos = models.ForeignKey('POS', related_name='entries', on_delete=models.PROTECT)
status = models.ForeignKey('Status', related_name='entries', on_delete=models.PROTECT)
frequency_1M = models.PositiveIntegerField(default=0)
frequency_300M = models.PositiveIntegerField(default=0)
schemata_count = models.PositiveIntegerField(null=False, default=0)
frames_count = models.PositiveIntegerField(null=False, default=0)
lexical_units_count = models.PositiveIntegerField(null=False, default=0)
class Meta:
ordering = ['name']
unique_together = ('name', 'pos',)
def __str__(self):
return '%s (%s)' % (self.name, self.pos)
class POS(models.Model):
tag = models.CharField(max_length=16, unique=True)
# name = TODO: wymaga lokalizacji
class Meta:
ordering = ['tag']
def __str__(self):
return self.tag
class Status(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 ExampleConnection(models.Model):
example = models.ForeignKey(Example, related_name='example_connections', on_delete=models.PROTECT)
lexical_unit = models.ForeignKey(LexicalUnit, related_name='example_connections', null=True, on_delete=models.PROTECT)
arguments = models.ManyToManyField(Argument, related_name='example_connections')
schema_connections = models.ManyToManyField('SchemaHook', related_name='example_connections')
class SchemaHook(models.Model):
subentry = models.ForeignKey(Subentry, related_name='schema_hooks', on_delete=models.PROTECT)
schema = models.ForeignKey(Schema, related_name='schema_hooks', on_delete=models.PROTECT)
position = models.ForeignKey(Position, related_name='schema_hooks', on_delete=models.PROTECT)
phrase_type = models.ForeignKey(PhraseType, related_name='schema_hooks', on_delete=models.PROTECT)
alternation = models.IntegerField(default=1)
def __str__(self):
return 'sub_%d_sch_%d_pos_%d_pt_%d_alt_%d_' % (self.subentry.id, self.schema.id, self.position.id,
self.phrase_type.id, self.alternation)
class ArgumentConnection(models.Model):
argument = models.ForeignKey(Argument, related_name='argument_connections', on_delete=models.PROTECT)
schema_connections = models.ManyToManyField('SchemaHook', related_name='argument_connections')