Commit 0db52f288346f19d4ad052e34af16927aba9bc0a
1 parent
849eccfc
Nieczasownikowe jednostki leksykalne
Showing
3 changed files
with
40 additions
and
13 deletions
semantics/static/js/semantics_lexical_units.js
... | ... | @@ -4,6 +4,7 @@ var free_luid = -1; // these ids will be temporarely given to new le |
4 | 4 | var free_sense; // what sense should be given to new lexical unit |
5 | 5 | var lexical_units_frames = []; |
6 | 6 | var lexical_units_num = []; |
7 | +var part_of_speech; | |
7 | 8 | |
8 | 9 | // store lexical units from database |
9 | 10 | function memorizeLexicalUnits(input_lexical_units) { |
... | ... | @@ -18,8 +19,10 @@ function memorizeLexicalUnits(input_lexical_units) { |
18 | 19 | function basicLexicalUnitsData(info){ |
19 | 20 | base = info.base; |
20 | 21 | free_sense = info.sense; |
22 | + part_of_speech = info.pos; | |
21 | 23 | } |
22 | 24 | |
25 | + | |
23 | 26 | // create new lexical_unit |
24 | 27 | function createLexicalUnit(refl, glossa, relation, to) { |
25 | 28 | |
... | ... | @@ -34,7 +37,7 @@ function createLexicalUnit(refl, glossa, relation, to) { |
34 | 37 | refl_text = ""; |
35 | 38 | } |
36 | 39 | |
37 | - var lu = {base: base + refl_text, glossa: "" + glossa, definition: "", id: free_luid, luid: -1, refl: refl, glossa: glossa, pos: "czasownik", sense: free_sense, relation: relation, to: to, location: ""}; | |
40 | + var lu = {base: base + refl_text, glossa: "" + glossa, definition: "", id: free_luid, luid: -1, refl: refl, glossa: glossa, pos: part_of_speech, sense: free_sense, relation: relation, to: to, location: ""}; | |
38 | 41 | var operation = {operation: 'add_unit', unit:lu}; |
39 | 42 | lexical_units.push(lu); |
40 | 43 | lexical_unit_examples[free_luid] = [] |
... | ... | @@ -441,7 +444,7 @@ function getLexicalUnit(luid) { |
441 | 444 | |
442 | 445 | |
443 | 446 | function addPhraseologicalUnit(mwe, glossa, relation, to) { |
444 | - var lu = {base: mwe, glossa: "" + glossa, definition: "", id: free_luid, luid: -1, refl: "false", glossa: glossa, pos: "czasownik", sense: "A", relation: relation, to: to, location: ""}; | |
447 | + var lu = {base: mwe, glossa: "" + glossa, definition: "", id: free_luid, luid: -1, refl: "false", glossa: glossa, pos: part_of_speech, sense: "A", relation: relation, to: to, location: ""}; | |
445 | 448 | var operation = {operation: 'add_unit', unit:lu}; |
446 | 449 | lexical_units.push(lu); |
447 | 450 | lexical_unit_examples[free_luid] = []; |
... | ... | @@ -451,7 +454,7 @@ function addPhraseologicalUnit(mwe, glossa, relation, to) { |
451 | 454 | } |
452 | 455 | |
453 | 456 | function unlockPhraseologicalUnit(mwe) { |
454 | - var lu = {base: mwe.lu.split('-')[0], glossa: "", definition: "", id: mwe.id, luid: mwe.luid, refl: false, glossa: "", pos: "czasownik", sense: mwe.lu.split('-')[1], relation: 2, to: -1, location: ""}; | |
457 | + var lu = {base: mwe.lu.split('-')[0], glossa: "", definition: "", id: mwe.id, luid: mwe.luid, refl: false, glossa: "", pos: part_of_speech, sense: mwe.lu.split('-')[1], relation: 2, to: -1, location: ""}; | |
455 | 458 | lexical_units.push(lu); |
456 | 459 | return mwe.id; |
457 | 460 | } |
... | ... |
semantics/static/js/semantics_view.js
... | ... | @@ -56,7 +56,7 @@ function changeSynsetInput() { |
56 | 56 | } |
57 | 57 | |
58 | 58 | function openMeaningsMenu() { |
59 | - if(window.lemma_id != getActualLemmaId(window.lemma_id)){ | |
59 | + if(window.lemma_id != getActualLemmaId(window.lemma_id)){ | |
60 | 60 | alertOldSchemas(); |
61 | 61 | } |
62 | 62 | else { |
... | ... | @@ -185,7 +185,7 @@ function displayMeanings() { |
185 | 185 | e.preventDefault(); |
186 | 186 | if (parseInt(f.relation) != 2) { |
187 | 187 | $.prompt.removeState('state12'); |
188 | - $.prompt.addState('state12', {title: 'Znaczenia', html: getFormContent(f) + getRelation(f) + "w stosunku do:<br />" + getSynsets(f.context, "czasownik"), buttons: {Wstecz: -1, Anuluj: 0, Zatwierdź: 1}, focus: 1, submit: submitSynsetSelection}, 'state11'); | |
188 | + $.prompt.addState('state12', {title: 'Znaczenia', html: getFormContent(f) + getRelation(f) + "w stosunku do:<br />" + getSynsets(f.context, part_of_speech), buttons: {Wstecz: -1, Anuluj: 0, Zatwierdź: 1}, focus: 1, submit: submitSynsetSelection}, 'state11'); | |
189 | 189 | $.prompt.goToState('state12'); |
190 | 190 | } else { |
191 | 191 | createLexicalUnit(f.refl, f.glossa, f.relation, -1); |
... | ... | @@ -207,12 +207,16 @@ function displayMeanings() { |
207 | 207 | |
208 | 208 | var getFormContent = |
209 | 209 | function(f) { |
210 | - var result = '<label>Zwrotny <input type="checkbox" name="refl" value="true" disabled'; | |
210 | + var result = ''; | |
211 | + if (part_of_speech == 'czasownik') { | |
212 | + result += '<label>Zwrotny <input type="checkbox" name="refl" value="true" disabled'; | |
211 | 213 | if (f.refl == 'true') { |
212 | 214 | result += ' checked'; |
213 | - } | |
214 | - result += '></label><br /><label>Glossa <input type="text" name="glossa" value="' + f.glossa + '" disabled></label><br />'; | |
215 | - return result; | |
215 | + } | |
216 | + result += '></label><br />'; | |
217 | + } | |
218 | + result += '<label>Glossa <input type="text" name="glossa" value="' + f.glossa + '" disabled></label><br />'; | |
219 | + return result; | |
216 | 220 | }; |
217 | 221 | |
218 | 222 | var getRelation = |
... | ... | @@ -262,6 +266,16 @@ function displayMeanings() { |
262 | 266 | } |
263 | 267 | }; |
264 | 268 | |
269 | + var addMeaningsHtml = | |
270 | + function() { | |
271 | + var result = ''; | |
272 | + if (part_of_speech == 'czasownik') { | |
273 | + result += '<label>Zwrotny <input type="checkbox" name="refl" value="true"></label><br />'; | |
274 | + } | |
275 | + result += '<label>Glossa <input type="text" name="glossa" value=""></label><br />'; | |
276 | + return result; | |
277 | + }; | |
278 | + | |
265 | 279 | var display_meanings = { |
266 | 280 | state0: { |
267 | 281 | title: 'Znaczenia', |
... | ... | @@ -272,8 +286,7 @@ function displayMeanings() { |
272 | 286 | }, |
273 | 287 | state1: { |
274 | 288 | title: 'Dodawanie znaczenia', |
275 | - html: '<label>Zwrotny <input type="checkbox" name="refl" value="true"></label><br />'+ | |
276 | - '<label>Glossa <input type="text" name="glossa" value=""></label><br />', | |
289 | + html: addMeaningsHtml(), | |
277 | 290 | buttons: { "Anuluj": -1, "Potwierdź": 1 }, |
278 | 291 | focus: 1, |
279 | 292 | submit:function(e,v,m,f){ |
... | ... | @@ -529,7 +542,7 @@ function changeLexicalUnits() { |
529 | 542 | { |
530 | 543 | title: 'Znaczenia', |
531 | 544 | html: '<label>Glossa <input type="text" name="glossa" value="' + gloss + '" disabled></label><br />' + |
532 | - getRelation(f) + "w stosunku do:<br />" + getSynsets(f.context, "czasownik"), | |
545 | + getRelation(f) + "w stosunku do:<br />" + getSynsets(f.context, part_of_speech), | |
533 | 546 | buttons: {Wstecz: -1, Anuluj: 0, Zatwierdź: 1}, |
534 | 547 | focus: 1, |
535 | 548 | submit: addPhraseology |
... | ... |
semantics/views.py
... | ... | @@ -290,12 +290,23 @@ def ajax_units(request, lemma_id): |
290 | 290 | |
291 | 291 | def create_units_context(lemma_id): |
292 | 292 | lemma = Lemma.objects.get(id=lemma_id) |
293 | + pos_en = lemma.entry_obj.pos.tag | |
294 | + pos = 'brak' | |
295 | + if pos_en == 'adj': | |
296 | + pos = 'przymiotnik' | |
297 | + elif pos_en == 'noun': | |
298 | + pos = 'rzeczownik' | |
299 | + elif pos_en == 'adv': | |
300 | + pos = 'przysłówek' | |
301 | + elif pos_en == 'verb': | |
302 | + pos = 'czasownik' | |
293 | 303 | lexical_units = lemma.entry_obj.meanings.order_by('base', 'sense') |
294 | 304 | # lexical_units = LexicalUnit.objects.filter(Q(base__startswith=lemma.entry + u' ', pos="czasownik")|Q(base__contains=u' '+lemma.entry+u' ', pos="czasownik")|Q(base__endswith=u' '+lemma.entry, pos="czasownik")|Q(base=lemma.entry, pos="czasownik")).order_by('base', 'sense') |
295 | 305 | |
296 | 306 | context = { |
297 | 307 | 'lexical_units': [{"id": lu.id, "luid": lu.luid, "base": lu.base, "sense": lu.sense, "pos": lu.pos, "glossa": lu.glossa, "definition": lu.definition, "location": location(lu)} for lu in lexical_units], |
298 | - 'informations': {'base': lemma.entry, 'sense': max(['A'] + [chr(ord(lu.sense) + 1) for lu in lexical_units.filter(luid=-1)])}, # TODO: 2 different free senses for with/whthout 'się' | |
308 | + 'informations': {'base': lemma.entry, 'sense': max(['A'] + [chr(ord(lu.sense) + 1) for lu in lexical_units.filter(luid=-1)]), # TODO: 2 different free senses for with/without 'się' | |
309 | + 'pos': pos} | |
299 | 310 | } |
300 | 311 | return context |
301 | 312 | |
... | ... |