diff --git a/dictionary/management/commands/get_pred_prepnp_jako_str2check.py b/dictionary/management/commands/get_pred_prepnp_jako_str2check.py new file mode 100644 index 0000000..8e9d0d4 --- /dev/null +++ b/dictionary/management/commands/get_pred_prepnp_jako_str2check.py @@ -0,0 +1,32 @@ +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 + 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