Commit 80b919c40639714990c39eb3a2b46a01e4ec9448

Authored by Bartłomiej Nitoń
1 parent c3920fdf

Added get_pred_prepnp_jako_str2check script listing entries to check.

dictionary/management/commands/get_pred_prepnp_jako_str2check.py 0 → 100644
  1 +from django.core.management.base import BaseCommand
  2 +
  3 +from dictionary.models import Lemma
  4 +
  5 +
  6 +class Command(BaseCommand):
  7 +
  8 + def handle(self, **options):
  9 + self.get_lemmas2check()
  10 +
  11 + def get_lemmas2check(self):
  12 + for lemma in Lemma.objects.filter(old=False).order_by('entry_obj__name'):
  13 + pred_prepnp_jako_str_exists = False
  14 + other_pred_exists = False
  15 + for schema in lemma.frames.all():
  16 + for pos in schema.positions.filter(categories__category='pred_controllee'):
  17 + for phrase_type in pos.arguments.all():
  18 + if self.phrase_type_is_prepnp_jako_str(phrase_type):
  19 + pred_prepnp_jako_str_exists = True
  20 + else:
  21 + other_pred_exists = True
  22 + if pred_prepnp_jako_str_exists and other_pred_exists:
  23 + print lemma
  24 + break
  25 +
  26 + def phrase_type_is_prepnp_jako_str(self, phrase_type):
  27 + if (phrase_type.text_rep == 'prepnp(jako,str)'):
  28 + return True
  29 + if (phrase_type.type == 'lex' and
  30 + phrase_type.atributes.get(type='TYP FRAZY').values.all()[0].argument.text_rep == 'prepnp(jako,str)'):
  31 + return True
  32 + return False
... ...