From 80b919c40639714990c39eb3a2b46a01e4ec9448 Mon Sep 17 00:00:00 2001
From: bniton <bartek.niton@gmail.com>
Date: Mon, 27 Aug 2018 17:14:36 +0200
Subject: [PATCH] Added get_pred_prepnp_jako_str2check script listing entries to check.

---
 dictionary/management/commands/get_pred_prepnp_jako_str2check.py | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+), 0 deletions(-)
 create mode 100644 dictionary/management/commands/get_pred_prepnp_jako_str2check.py

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
--
libgit2 0.22.2