get_pred_prepnp_jako_str2check.py
1.74 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
from django.core.management.base import BaseCommand
from dictionary.models import Lemma
class Command(BaseCommand):
def handle(self, **options):
self.get_lemmas2check()
def get_lemmas2check(self):
for lemma in Lemma.objects.filter(old=False).order_by('entry_obj__name'):
pred_prepnp_jako_str_exists = False
other_pred_exists = False
for schema in lemma.frames.all():
for pos in schema.positions.filter(categories__category='pred_controllee'):
for phrase_type in pos.arguments.all():
if self.phrase_type_is_prepnp_jako_str(phrase_type):
pred_prepnp_jako_str_exists = True
elif self.phrase_type_is_prepadjp_jako_str(phrase_type):
pred_prepnp_jako_str_exists = True
else:
other_pred_exists = True
if pred_prepnp_jako_str_exists and other_pred_exists:
print lemma
break
def phrase_type_is_prepnp_jako_str(self, phrase_type):
if (phrase_type.text_rep == 'prepnp(jako,str)'):
return True
if (phrase_type.type == 'lex' and
phrase_type.atributes.get(type='TYP FRAZY').values.all()[0].argument.text_rep == 'prepnp(jako,str)'):
return True
return False
def phrase_type_is_prepadjp_jako_str(self, phrase_type):
if (phrase_type.text_rep == 'prepadjp(jako,str)'):
return True
if (phrase_type.type == 'lex' and
phrase_type.atributes.get(type='TYP FRAZY').values.all()[0].argument.text_rep == 'prepadjp(jako,str)'):
return True
return False