models.py
2.16 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
# -*- coding: utf-8 -*-
from django.db import models
###############################################
################## plWordnet ##################
###############################################
class Synset(models.Model):
# identyfikator ze słowosieci
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 słowosieci (jeśli jest)
luid = models.IntegerField(null=True)
# podstawa jednostki leksykalnej
base = models.CharField(max_length=150)
# numer znaczenia
sense = models.CharField(max_length=5)
# część mowy
pos = models.CharField(max_length=20)
# wskaźnik do synsetu, w którym się znajduje
synset = models.ForeignKey(Synset, null=True)
# definition
definition = models.TextField(default="")
# glossa
glossa = models.TextField(default="")
def __unicode__(self):
return u'%s-%s' % (self.base, self.sense)
def actual_frames(self):
return self.frames.filter(next__isnull=True, removed=False)
def is_reflexive(self):
base_parts = self.base.split()
if len(base_parts) > 1 and base_parts[1] == u'się':
return True
return False
class Meta:
unique_together = ('base', 'sense', 'pos',)
class Hypernymy(models.Model): # hiperonimia jest odwrotna
# hiponim childa
parent = models.ForeignKey(Synset, related_name='hyponym')
# hiperonim parenta
child = models.ForeignKey(Synset, related_name='hypernym')
class Meta:
unique_together = ('parent', 'child',)
class Synonymy(models.Model): # relacja jest symetryczna, dane zwielokrotnione
parent = models.ForeignKey(Synset, related_name='synset')
child = models.ForeignKey(Synset, related_name='synonym')
class Meta:
unique_together = ('parent', 'child',)