models.py
2.38 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
from django.db import models
class Synset(models.Model):
id = models.IntegerField(primary_key=True)
def __unicode__(self):
text_rep = u''
units_in_synset = LexicalUnit.objects.filter(synset__id=self.id)
if units_in_synset.exists():
first_lex_unit = units_in_synset.order_by('luid')[0]
text_rep = unicode(first_lex_unit)
return text_rep
class LexicalUnit(models.Model):
# identyfikator ze Slowosieci
luid = models.IntegerField(primary_key=True)
# podstawa jednostki leksykalnej
base = models.CharField(max_length=150)
# numer znaczenia
sense = models.CharField(max_length=5)
# czesc mowy
pos = models.CharField(max_length=20)
# wskaznik do synsetu
synset = models.ForeignKey(Synset, null=True, related_name='lus')
# definicja
definition = models.TextField(default="")
def __unicode__(self):
return u'%s-%s' % (self.base, self.sense)
class Meta:
unique_together = ('base', 'sense', 'pos',)
class Relation(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(max_length=80)
parent = models.ForeignKey('Relation', null=True, related_name='child')
def __unicode__(self):
text_rep = u'%s' % self.name
if self.parent:
text_rep = u'%s --> %s' % (unicode(self.parent), self.name)
return text_rep
class SynsetLink(models.Model):
relation = models.ForeignKey(Relation, related_name='synset_links')
parent = models.ForeignKey(Synset, related_name='sources')
child = models.ForeignKey(Synset, related_name='targets')
def __unicode__(self):
return u'%s --%s--> %s' % (unicode(self.child),
unicode(self.relation),
unicode(self.parent))
class Meta:
unique_together = ('parent', 'child', 'relation')
class LexicalUnitLink(models.Model):
relation = models.ForeignKey(Relation, related_name='lu_links')
parent = models.ForeignKey(LexicalUnit, related_name='sources')
child = models.ForeignKey(LexicalUnit, related_name='targets')
def __unicode__(self):
return u'%s --%s--> %s' % (unicode(self.child),
unicode(self.relation),
unicode(self.parent))
class Meta:
unique_together = ('parent', 'child', 'relation')