diff --git a/semantics/phraseology_generator.py b/semantics/phraseology_generator.py index 48ff139..bc3179d 100644 --- a/semantics/phraseology_generator.py +++ b/semantics/phraseology_generator.py @@ -3,8 +3,7 @@ from dictionary.models import sort_arguments, sort_positions, sortatributes from settings import MORFEUSZ2 -def lexicalisation(argument, categories, base): - subj = is_subj(categories) +def lexicalisation(argument, subj, base, negativity): b = argument.type if b == 'fixed': return (get_words(sortatributes(argument)[-1]), []) @@ -15,16 +14,16 @@ def lexicalisation(argument, categories, base): lexicalisation_type = lexicalisation_parameters[0].values.all()[0].argument.type lexicalisation_parameters = sortatributes(lexicalisation_parameters[0].values.all()[0].argument) if lexicalisation_type == 'np': # np(case), number, nouns, atr - nps = get_nps(get_case(lexicalisation_parameters[0], subj), get_number(attributes[1], subj), get_words(attributes[2]), attributes[3]) + nps = get_nps(get_case(lexicalisation_parameters[0], subj, negativity), get_number(attributes[1], subj), get_words(attributes[2]), attributes[3]) return (nps, get_verb(base, get_number(attributes[1], subj), subj)) elif lexicalisation_type == 'prepnp': #prepnp(prep, case), number, nouns, atr - prepnps = get_prepnps(get_preposition(lexicalisation_parameters[0]), get_case(lexicalisation_parameters[1], subj), get_number(attributes[1], subj), get_words(attributes[2]), attributes[3]) + prepnps = get_prepnps(get_preposition(lexicalisation_parameters[0]), get_case(lexicalisation_parameters[1], subj, negativity), get_number(attributes[1], subj), get_words(attributes[2]), attributes[3]) return (prepnps, []) elif lexicalisation_type == 'adjp': # adjp(case), number, gender, degree, adjectives, atr - adjps = get_adjps(get_case(lexicalisation_parameters[0], subj), get_number(attributes[1], subj), get_gender(attributes[2]), get_degree(attributes[3]), get_words(attributes[4]), attributes[5]) + adjps = get_adjps(get_case(lexicalisation_parameters[0], subj, negativity), get_number(attributes[1], subj), get_gender(attributes[2]), get_degree(attributes[3]), get_words(attributes[4]), attributes[5]) return (adjps, get_verb(base, get_number(attributes[1], subj), subj)) elif lexicalisation_type == 'prepadjp': #prepadjp(prep, case), number, gender, degree, adjectives, atr - prepadjps = get_prepadjps(get_preposition(lexicalisation_parameters[0]), get_case(lexicalisation_parameters[1], subj), get_number(attributes[1], subj), get_gender(attributes[2]), get_degree(attributes[3]), get_words(attributes[4]), attributes[5]) + prepadjps = get_prepadjps(get_preposition(lexicalisation_parameters[0]), get_case(lexicalisation_parameters[1], subj, False), get_number(attributes[1], subj), get_gender(attributes[2]), get_degree(attributes[3]), get_words(attributes[4]), attributes[5]) return (prepadjps, []) else: return ([], []) @@ -46,11 +45,13 @@ def get_words(attribute): words = [word.text[1:-1] for word in attribute.values.all()] return words -def get_case(attribute, is_subj): +def get_case(attribute, is_subj, negativity): case = attribute.values.all()[0].parameter.type.name if case == u'str': if is_subj: case = u'nom' + elif negativity: + case = u'gen' else: case = u'acc' return case diff --git a/semantics/static/js/semantics_lexical_units.js b/semantics/static/js/semantics_lexical_units.js index 676615e..45ac021 100644 --- a/semantics/static/js/semantics_lexical_units.js +++ b/semantics/static/js/semantics_lexical_units.js @@ -240,8 +240,18 @@ function getMeaningsSelectionForFrame(frame_id) { if (vrb.length == 0) { var lex = {lemma: [base], pre: pre, args: options}; if (hasRefl(sch)) { - lex.lemma = [base + " się"]; - } + if (isNeg(sch)) { + lex.lemma = ["nie " + base + " się"]; + } else { + lex.lemma = [base + " się"]; + } + } else { + if (isNeg(sch)) { + lex.lemma = ["nie " + base]; + } else { + lex.lemma = [base]; + } + } lexicalisation.push(lex); } else { var lex = {lemma: vrb, pre: pre, args: options}; diff --git a/semantics/static/js/semantics_schemas.js b/semantics/static/js/semantics_schemas.js index 895f3aa..16f4553 100644 --- a/semantics/static/js/semantics_schemas.js +++ b/semantics/static/js/semantics_schemas.js @@ -233,3 +233,22 @@ function hasRefl(schema) { } return false; } + +function isNeg(schema) { + var sid = schemaId(schema); + var i, j; + for (i = 0; i < subentry_display.length; i++) { + var char_display = subentry_display[i].characteristic_display; + for (j = 0; j < subentry_display[i].schemas.length; j++) { + if (subentry_display[i].schemas[j].schema_id == sid) { + if (char_display.search('neg') >= 0) { + return true; + } else { + return false; + } + } + } + } + return false; +} + diff --git a/semantics/views.py b/semantics/views.py index 58c678d..82f7509 100644 --- a/semantics/views.py +++ b/semantics/views.py @@ -19,7 +19,7 @@ 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 semantics.phraseology_generator import lexicalisation, is_subj from settings import MORFEUSZ2 @@ -454,7 +454,7 @@ def ajax_schemas(request, lemma_id): for i, c, a, p in zip(idents, schema_ids, row, ordered_positions): astr, aobj = a if aobj is not None and aobj.is_phraseologic(): - tmp = lexicalisation(aobj, p.categories.all(), lemma.entry_obj.name) + tmp = lexicalisation(aobj, is_subj(p.categories.all()), lemma.entry_obj.name, ('neg' in characteristics[characteristic_id])) lex, vrb = tmp else: lex, vrb = ([], [])