Commit 86e357ef0808d524935fa581e379e3f38fb48991

Authored by Tomasz Bartosiak
1 parent 8089d5e6

negacja w lematach

semantics/phraseology_generator.py
@@ -3,8 +3,7 @@ @@ -3,8 +3,7 @@
3 from dictionary.models import sort_arguments, sort_positions, sortatributes 3 from dictionary.models import sort_arguments, sort_positions, sortatributes
4 from settings import MORFEUSZ2 4 from settings import MORFEUSZ2
5 5
6 -def lexicalisation(argument, categories, base):  
7 - subj = is_subj(categories) 6 +def lexicalisation(argument, subj, base, negativity):
8 b = argument.type 7 b = argument.type
9 if b == 'fixed': 8 if b == 'fixed':
10 return (get_words(sortatributes(argument)[-1]), []) 9 return (get_words(sortatributes(argument)[-1]), [])
@@ -15,16 +14,16 @@ def lexicalisation(argument, categories, base): @@ -15,16 +14,16 @@ def lexicalisation(argument, categories, base):
15 lexicalisation_type = lexicalisation_parameters[0].values.all()[0].argument.type 14 lexicalisation_type = lexicalisation_parameters[0].values.all()[0].argument.type
16 lexicalisation_parameters = sortatributes(lexicalisation_parameters[0].values.all()[0].argument) 15 lexicalisation_parameters = sortatributes(lexicalisation_parameters[0].values.all()[0].argument)
17 if lexicalisation_type == 'np': # np(case), number, nouns, atr 16 if lexicalisation_type == 'np': # np(case), number, nouns, atr
18 - nps = get_nps(get_case(lexicalisation_parameters[0], subj), get_number(attributes[1], subj), get_words(attributes[2]), attributes[3]) 17 + nps = get_nps(get_case(lexicalisation_parameters[0], subj, negativity), get_number(attributes[1], subj), get_words(attributes[2]), attributes[3])
19 return (nps, get_verb(base, get_number(attributes[1], subj), subj)) 18 return (nps, get_verb(base, get_number(attributes[1], subj), subj))
20 elif lexicalisation_type == 'prepnp': #prepnp(prep, case), number, nouns, atr 19 elif lexicalisation_type == 'prepnp': #prepnp(prep, case), number, nouns, atr
21 - 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]) 20 + 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])
22 return (prepnps, []) 21 return (prepnps, [])
23 elif lexicalisation_type == 'adjp': # adjp(case), number, gender, degree, adjectives, atr 22 elif lexicalisation_type == 'adjp': # adjp(case), number, gender, degree, adjectives, atr
24 - 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]) 23 + 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])
25 return (adjps, get_verb(base, get_number(attributes[1], subj), subj)) 24 return (adjps, get_verb(base, get_number(attributes[1], subj), subj))
26 elif lexicalisation_type == 'prepadjp': #prepadjp(prep, case), number, gender, degree, adjectives, atr 25 elif lexicalisation_type == 'prepadjp': #prepadjp(prep, case), number, gender, degree, adjectives, atr
27 - 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]) 26 + 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])
28 return (prepadjps, []) 27 return (prepadjps, [])
29 else: 28 else:
30 return ([], []) 29 return ([], [])
@@ -46,11 +45,13 @@ def get_words(attribute): @@ -46,11 +45,13 @@ def get_words(attribute):
46 words = [word.text[1:-1] for word in attribute.values.all()] 45 words = [word.text[1:-1] for word in attribute.values.all()]
47 return words 46 return words
48 47
49 -def get_case(attribute, is_subj): 48 +def get_case(attribute, is_subj, negativity):
50 case = attribute.values.all()[0].parameter.type.name 49 case = attribute.values.all()[0].parameter.type.name
51 if case == u'str': 50 if case == u'str':
52 if is_subj: 51 if is_subj:
53 case = u'nom' 52 case = u'nom'
  53 + elif negativity:
  54 + case = u'gen'
54 else: 55 else:
55 case = u'acc' 56 case = u'acc'
56 return case 57 return case
semantics/static/js/semantics_lexical_units.js
@@ -240,8 +240,18 @@ function getMeaningsSelectionForFrame(frame_id) { @@ -240,8 +240,18 @@ function getMeaningsSelectionForFrame(frame_id) {
240 if (vrb.length == 0) { 240 if (vrb.length == 0) {
241 var lex = {lemma: [base], pre: pre, args: options}; 241 var lex = {lemma: [base], pre: pre, args: options};
242 if (hasRefl(sch)) { 242 if (hasRefl(sch)) {
243 - lex.lemma = [base + " się"];  
244 - } 243 + if (isNeg(sch)) {
  244 + lex.lemma = ["nie " + base + " się"];
  245 + } else {
  246 + lex.lemma = [base + " się"];
  247 + }
  248 + } else {
  249 + if (isNeg(sch)) {
  250 + lex.lemma = ["nie " + base];
  251 + } else {
  252 + lex.lemma = [base];
  253 + }
  254 + }
245 lexicalisation.push(lex); 255 lexicalisation.push(lex);
246 } else { 256 } else {
247 var lex = {lemma: vrb, pre: pre, args: options}; 257 var lex = {lemma: vrb, pre: pre, args: options};
semantics/static/js/semantics_schemas.js
@@ -233,3 +233,22 @@ function hasRefl(schema) { @@ -233,3 +233,22 @@ function hasRefl(schema) {
233 } 233 }
234 return false; 234 return false;
235 } 235 }
  236 +
  237 +function isNeg(schema) {
  238 + var sid = schemaId(schema);
  239 + var i, j;
  240 + for (i = 0; i < subentry_display.length; i++) {
  241 + var char_display = subentry_display[i].characteristic_display;
  242 + for (j = 0; j < subentry_display[i].schemas.length; j++) {
  243 + if (subentry_display[i].schemas[j].schema_id == sid) {
  244 + if (char_display.search('neg') >= 0) {
  245 + return true;
  246 + } else {
  247 + return false;
  248 + }
  249 + }
  250 + }
  251 + }
  252 + return false;
  253 +}
  254 +
semantics/views.py
@@ -19,7 +19,7 @@ from semantics.forms import GeneralSelPrefForm, RelationalSelPrefForm, RoleForm, @@ -19,7 +19,7 @@ from semantics.forms import GeneralSelPrefForm, RelationalSelPrefForm, RoleForm,
19 from semantics.saving import modify_frames, update_meanings 19 from semantics.saving import modify_frames, update_meanings
20 from semantics.validation import validate_schemas, validate_frames, validate_lexical_units 20 from semantics.validation import validate_schemas, validate_frames, validate_lexical_units
21 21
22 -from semantics.phraseology_generator import lexicalisation 22 +from semantics.phraseology_generator import lexicalisation, is_subj
23 23
24 from settings import MORFEUSZ2 24 from settings import MORFEUSZ2
25 25
@@ -454,7 +454,7 @@ def ajax_schemas(request, lemma_id): @@ -454,7 +454,7 @@ def ajax_schemas(request, lemma_id):
454 for i, c, a, p in zip(idents, schema_ids, row, ordered_positions): 454 for i, c, a, p in zip(idents, schema_ids, row, ordered_positions):
455 astr, aobj = a 455 astr, aobj = a
456 if aobj is not None and aobj.is_phraseologic(): 456 if aobj is not None and aobj.is_phraseologic():
457 - tmp = lexicalisation(aobj, p.categories.all(), lemma.entry_obj.name) 457 + tmp = lexicalisation(aobj, is_subj(p.categories.all()), lemma.entry_obj.name, ('neg' in characteristics[characteristic_id]))
458 lex, vrb = tmp 458 lex, vrb = tmp
459 else: 459 else:
460 lex, vrb = ([], []) 460 lex, vrb = ([], [])