from django.contrib.contenttypes.fields import GenericRelation from django.db import models from examples.models import Example from meanings.models import LexicalUnit from semantics.models import Argument, Frame 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) import_error = models.BooleanField(default=False) assignments = GenericRelation("users.Assignment", content_type_field="subject_ct", object_id_field="subject_id") 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) description = models.TextField() 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') class RealisationDescription(models.Model): frame = models.ForeignKey(Frame, related_name='alternation_meanings', on_delete=models.PROTECT) schema = models.ForeignKey(Schema, related_name='alternation_meanings', on_delete=models.PROTECT) alternation = models.IntegerField(default=1) description = models.TextField()