From 665a23d592e3ebb777407beaa64da01f5b382bfc Mon Sep 17 00:00:00 2001
From: Tomasz Bartosiak <tomasz.bartosiak@mozart.ipipan.waw.pl>
Date: Wed, 27 Apr 2016 13:27:47 +0200
Subject: [PATCH] xp in phraseology

---
 semantics/views.py | 60 ++----------------------------------------------------------
 1 file changed, 2 insertions(+), 58 deletions(-)

diff --git a/semantics/views.py b/semantics/views.py
index 7e26fa1..18690f3 100644
--- a/semantics/views.py
+++ b/semantics/views.py
@@ -19,6 +19,8 @@ from semantics.forms import GeneralSelPrefForm, RelationalSelPrefForm, RoleForm,
 from semantics.saving import modify_frames, update_meanings
 from semantics.validation import validate_schemas, validate_frames, validate_lexical_units
 
+from semantics.phraseology_generator import lexicalisation
+
 from settings import MORFEUSZ2
 
 ####################################### render #####################################
@@ -476,64 +478,6 @@ def ajax_schemas(request, lemma_id):
 
     return context
   
-def lexicalisation(argument):
-    b = argument.type
-    if b == 'fixed':
-        return get_words(sortatributes(argument)[-1])
-    attributes = sortatributes(argument)
-    lexicalisation_type = attributes[0].values.all()[0].argument.type
-    lexicalisation_parameters = sortatributes(attributes[0].values.all()[0].argument)
-    if lexicalisation_type == 'np': # np(case), number, nouns, atr
-        nps = get_nps(get_case(lexicalisation_parameters[0]), get_number(attributes[1]), get_words(attributes[2]), attributes[3])
-        return nps
-    elif lexicalisation_type == 'prepnp': #prepnp(prep, case), number, nouns, atr
-        prepnps = get_prepnps(get_preposition(lexicalisation_parameters[0]), get_case(lexicalisation_parameters[1]), get_number(attributes[1]), get_words(attributes[2]), attributes[3])
-        return prepnps
-    else:
-        return []
-    return []
-
-def get_preposition(attribute):
-    return attribute.values.all()[0].parameter.type.name
-
-def get_words(attribute):
-    words = [word.text[1:-1] for word in attribute.values.all()]
-    return words
-
-def get_case(attribute):
-    case = attribute.values.all()[0].parameter.type.name
-    if case == u'str':
-        case = u'acc'
-    return case
-
-def get_number(attribute):
-    number = attribute.values.all()[0].parameter.type.name
-    return number
-
-def get_nps(case, number, nouns, _atr):
-    result = []
-    for noun in nouns:
-        options = [(interp.orth, interp.getTag(MORFEUSZ2)) for interp in MORFEUSZ2.generate(noun.encode('utf8'))]
-        if case != u'_':
-            filtered = []
-            for option in options:
-                (orth, tag) = option
-                if case in tag:
-                    filtered.append(option)
-            options = filtered
-        if number != u'_':
-            filtered = []
-            for option in options:
-                (orth, tag) = option
-                if number in tag:
-                    filtered.append(option)
-            options = filtered
-    return [orth for orth, _ in options]
-
-def get_prepnps(prep, case, number, nouns, _atr):
-    nps = get_nps(case, number, nouns, _atr)
-    return [prep + ' ' + np for np in nps]
-
 @render('examples.json')   
 @ajax(method='get', encode_result=False)
 def ajax_examples(request, lemma_id):
--
libgit2 0.22.2