Commit 86e357ef0808d524935fa581e379e3f38fb48991
1 parent
8089d5e6
negacja w lematach
Showing
4 changed files
with
41 additions
and
11 deletions
semantics/phraseology_generator.py
... | ... | @@ -3,8 +3,7 @@ |
3 | 3 | from dictionary.models import sort_arguments, sort_positions, sortatributes |
4 | 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 | 7 | b = argument.type |
9 | 8 | if b == 'fixed': |
10 | 9 | return (get_words(sortatributes(argument)[-1]), []) |
... | ... | @@ -15,16 +14,16 @@ def lexicalisation(argument, categories, base): |
15 | 14 | lexicalisation_type = lexicalisation_parameters[0].values.all()[0].argument.type |
16 | 15 | lexicalisation_parameters = sortatributes(lexicalisation_parameters[0].values.all()[0].argument) |
17 | 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 | 18 | return (nps, get_verb(base, get_number(attributes[1], subj), subj)) |
20 | 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 | 21 | return (prepnps, []) |
23 | 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 | 24 | return (adjps, get_verb(base, get_number(attributes[1], subj), subj)) |
26 | 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 | 27 | return (prepadjps, []) |
29 | 28 | else: |
30 | 29 | return ([], []) |
... | ... | @@ -46,11 +45,13 @@ def get_words(attribute): |
46 | 45 | words = [word.text[1:-1] for word in attribute.values.all()] |
47 | 46 | return words |
48 | 47 | |
49 | -def get_case(attribute, is_subj): | |
48 | +def get_case(attribute, is_subj, negativity): | |
50 | 49 | case = attribute.values.all()[0].parameter.type.name |
51 | 50 | if case == u'str': |
52 | 51 | if is_subj: |
53 | 52 | case = u'nom' |
53 | + elif negativity: | |
54 | + case = u'gen' | |
54 | 55 | else: |
55 | 56 | case = u'acc' |
56 | 57 | return case |
... | ... |
semantics/static/js/semantics_lexical_units.js
... | ... | @@ -240,8 +240,18 @@ function getMeaningsSelectionForFrame(frame_id) { |
240 | 240 | if (vrb.length == 0) { |
241 | 241 | var lex = {lemma: [base], pre: pre, args: options}; |
242 | 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 | 255 | lexicalisation.push(lex); |
246 | 256 | } else { |
247 | 257 | var lex = {lemma: vrb, pre: pre, args: options}; |
... | ... |
semantics/static/js/semantics_schemas.js
... | ... | @@ -233,3 +233,22 @@ function hasRefl(schema) { |
233 | 233 | } |
234 | 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 | 19 | from semantics.saving import modify_frames, update_meanings |
20 | 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 | 24 | from settings import MORFEUSZ2 |
25 | 25 | |
... | ... | @@ -454,7 +454,7 @@ def ajax_schemas(request, lemma_id): |
454 | 454 | for i, c, a, p in zip(idents, schema_ids, row, ordered_positions): |
455 | 455 | astr, aobj = a |
456 | 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 | 458 | lex, vrb = tmp |
459 | 459 | else: |
460 | 460 | lex, vrb = ([], []) |
... | ... |