Commit 7211e57d53f4c3827ddaf1f09a78d71797dfb77f
1 parent
a5734633
Wyświetlanie lokacji dodanej jednostki leksykalnej
Showing
5 changed files
with
50 additions
and
7 deletions
semantics/static/js/semantics_frames.js
@@ -64,6 +64,10 @@ function displayFrames(){ | @@ -64,6 +64,10 @@ function displayFrames(){ | ||
64 | u += '\n'; | 64 | u += '\n'; |
65 | } | 65 | } |
66 | u += lexical_units[lid].definition; | 66 | u += lexical_units[lid].definition; |
67 | + if (lexical_units[lid].definition != '') { | ||
68 | + u += '\n'; | ||
69 | + } | ||
70 | + u += lexical_units[lid].location; | ||
67 | u +='"> '; | 71 | u +='"> '; |
68 | u += lexical_units[lid].base + '-' + lexical_units[lid].sense; | 72 | u += lexical_units[lid].base + '-' + lexical_units[lid].sense; |
69 | u += '</strong>'; | 73 | u += '</strong>'; |
semantics/static/js/semantics_lexical_units.js
@@ -34,7 +34,7 @@ function createLexicalUnit(refl, glossa, relation, to) { | @@ -34,7 +34,7 @@ function createLexicalUnit(refl, glossa, relation, to) { | ||
34 | refl_text = ""; | 34 | refl_text = ""; |
35 | } | 35 | } |
36 | 36 | ||
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}; | 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: ""}; |
38 | var operation = {operation: 'add_unit', unit:lu}; | 38 | var operation = {operation: 'add_unit', unit:lu}; |
39 | lexical_units.push(lu); | 39 | lexical_units.push(lu); |
40 | lexical_unit_examples[free_luid] = [] | 40 | lexical_unit_examples[free_luid] = [] |
@@ -88,6 +88,15 @@ function setGlossa(luid, glossa) { | @@ -88,6 +88,15 @@ function setGlossa(luid, glossa) { | ||
88 | units_operations.push({operation: 'set_glossa', unit: luid, value: lexical_units[i].glossa}); | 88 | units_operations.push({operation: 'set_glossa', unit: luid, value: lexical_units[i].glossa}); |
89 | } | 89 | } |
90 | 90 | ||
91 | +function getLocation(luid) { | ||
92 | + if (isPLWNUnit(luid)){ | ||
93 | + var lu = lexical_units[indexOfId(lexical_units, luid)]; | ||
94 | + return lu.location; | ||
95 | + } else { | ||
96 | + return ""; | ||
97 | + } | ||
98 | +} | ||
99 | + | ||
91 | // save all changes to meanings (lexical units) | 100 | // save all changes to meanings (lexical units) |
92 | function saveMeanings() { | 101 | function saveMeanings() { |
93 | $.ajax({ | 102 | $.ajax({ |
@@ -119,7 +128,15 @@ function getMeanings() { | @@ -119,7 +128,15 @@ function getMeanings() { | ||
119 | 128 | ||
120 | var i; | 129 | var i; |
121 | for (i = 0; i < lexical_units.length; i++) { | 130 | for (i = 0; i < lexical_units.length; i++) { |
122 | - display += "<input type = \"radio\" name = \"meaning\" value = \"" + lexical_units[i].id + "\">" + lexical_units[i].base + "-" + lexical_units[i].sense + " <i>" + lexical_units[i].definition + "</i><br><div id=\"glossa_" + lexical_units[i].id + "\">" + lexical_units[i].glossa + "</div>"; | 131 | + display += "<input type = \"radio\" name = \"meaning\" value = \"" + lexical_units[i].id + "\">" + lexical_units[i].base + "-" + lexical_units[i].sense + "<div id=\"glossa_" + lexical_units[i].id + "\">" + " <i>" + lexical_units[i].definition + "</i>"; |
132 | + if (lexical_units[i].definition != "") { | ||
133 | + display += "<br>"; | ||
134 | + } | ||
135 | + display += lexical_units[i].glossa | ||
136 | + if (lexical_units[i].glossa != "") { | ||
137 | + display += "<br>"; | ||
138 | + } | ||
139 | + display += lexical_units[i].location + "</div>"; | ||
123 | } | 140 | } |
124 | 141 | ||
125 | return display; | 142 | return display; |
semantics/static/js/semantics_view.js
@@ -767,6 +767,7 @@ function frameClick(clicked_id) { | @@ -767,6 +767,7 @@ function frameClick(clicked_id) { | ||
767 | $('#assign_role').attr('disabled', "True"); | 767 | $('#assign_role').attr('disabled', "True"); |
768 | $('#add_preference').attr('disabled', "True"); | 768 | $('#add_preference').attr('disabled', "True"); |
769 | $('#delete').attr('disabled', "True"); | 769 | $('#delete').attr('disabled', "True"); |
770 | + $('#multi_lus').attr('disabled', "True"); | ||
770 | $('#change_lus').attr('disabled', "True"); | 771 | $('#change_lus').attr('disabled', "True"); |
771 | $('#change_opinion').attr('disabled', "True"); | 772 | $('#change_opinion').attr('disabled', "True"); |
772 | } else { | 773 | } else { |
@@ -778,6 +779,7 @@ function frameClick(clicked_id) { | @@ -778,6 +779,7 @@ function frameClick(clicked_id) { | ||
778 | $('#assign_role').attr('disabled', "True"); | 779 | $('#assign_role').attr('disabled', "True"); |
779 | $('#add_preference').attr('disabled', "True"); | 780 | $('#add_preference').attr('disabled', "True"); |
780 | $('#delete').removeAttr('disabled'); | 781 | $('#delete').removeAttr('disabled'); |
782 | + $('#multi_lus').removeAttr('disabled'); | ||
781 | $('#change_lus').removeAttr('disabled'); | 783 | $('#change_lus').removeAttr('disabled'); |
782 | $('#change_opinion').removeAttr('disabled'); | 784 | $('#change_opinion').removeAttr('disabled'); |
783 | } | 785 | } |
@@ -795,6 +797,7 @@ function frameClick(clicked_id) { | @@ -795,6 +797,7 @@ function frameClick(clicked_id) { | ||
795 | $('#assign_role').attr('disabled', "True"); | 797 | $('#assign_role').attr('disabled', "True"); |
796 | $('#add_preference').attr('disabled', "True"); | 798 | $('#add_preference').attr('disabled', "True"); |
797 | $('#delete').attr('disabled', "True"); | 799 | $('#delete').attr('disabled', "True"); |
800 | + $('#multi_lus').attr('disabled', "True"); | ||
798 | $('#change_lus').attr('disabled', "True"); | 801 | $('#change_lus').attr('disabled', "True"); |
799 | $('#change_opinion').attr('disabled', "True"); | 802 | $('#change_opinion').attr('disabled', "True"); |
800 | } else { | 803 | } else { |
@@ -812,6 +815,7 @@ function frameClick(clicked_id) { | @@ -812,6 +815,7 @@ function frameClick(clicked_id) { | ||
812 | $('#assign_role').removeAttr('disabled'); | 815 | $('#assign_role').removeAttr('disabled'); |
813 | $('#add_preference').removeAttr('disabled'); | 816 | $('#add_preference').removeAttr('disabled'); |
814 | $('#delete').removeAttr('disabled'); | 817 | $('#delete').removeAttr('disabled'); |
818 | + $('#multi_lus').removeAttr('disabled'); | ||
815 | $('#change_lus').removeAttr('disabled'); | 819 | $('#change_lus').removeAttr('disabled'); |
816 | $('#change_opinion').removeAttr('disabled'); | 820 | $('#change_opinion').removeAttr('disabled'); |
817 | } | 821 | } |
semantics/templates/semantics.html
@@ -99,6 +99,8 @@ | @@ -99,6 +99,8 @@ | ||
99 | <button type="button" onclick="createFrame()" id="create_frame">Nowa rama</button> | 99 | <button type="button" onclick="createFrame()" id="create_frame">Nowa rama</button> |
100 | <button type="button" onclick="removeFromFrame()" id="delete" disabled="True">Usuń</button> | 100 | <button type="button" onclick="removeFromFrame()" id="delete" disabled="True">Usuń</button> |
101 | <br/> | 101 | <br/> |
102 | + <button type="button" onclick="changeLexicalUnits()" id="multi_lus" disabled="True">Jednostki wielowyrazowe</button> | ||
103 | + <br/> | ||
102 | <button type="button" onclick="changeLexicalUnits()" id="change_lus" disabled="True">Zmień jednostki</button> | 104 | <button type="button" onclick="changeLexicalUnits()" id="change_lus" disabled="True">Zmień jednostki</button> |
103 | <button type="button" onclick="changeOpinion()" id="change_opinion" disabled="True">Ustaw ocenę</button> | 105 | <button type="button" onclick="changeOpinion()" id="change_opinion" disabled="True">Ustaw ocenę</button> |
104 | <br/> | 106 | <br/> |
semantics/views.py
@@ -3,7 +3,9 @@ | @@ -3,7 +3,9 @@ | ||
3 | from semantics.models import SemanticRole, SemanticFrame, Complement, \ | 3 | from semantics.models import SemanticRole, SemanticFrame, Complement, \ |
4 | LexicalUnit, FrameRankings, SemanticRolesDisplay, \ | 4 | LexicalUnit, FrameRankings, SemanticRolesDisplay, \ |
5 | LexicalUnitExamples, SelectivePreferenceRelations, \ | 5 | LexicalUnitExamples, SelectivePreferenceRelations, \ |
6 | - GeneralSelectivePreference, FrameOpinion | 6 | + GeneralSelectivePreference, FrameOpinion, Synset |
7 | + | ||
8 | +from wordnet.models import Hypernymy, Synonymy | ||
7 | 9 | ||
8 | from dictionary.models import Frame_Char_Model, Lemma, Lemma_Status, \ | 10 | from dictionary.models import Frame_Char_Model, Lemma, Lemma_Status, \ |
9 | sort_arguments, sort_positions | 11 | sort_arguments, sort_positions |
@@ -72,7 +74,8 @@ def reorder_history(frames_list): | @@ -72,7 +74,8 @@ def reorder_history(frames_list): | ||
72 | def ajax_frames(request, lemma_id): | 74 | def ajax_frames(request, lemma_id): |
73 | 75 | ||
74 | lemma = Lemma.objects.get(id=lemma_id, old=False) | 76 | lemma = Lemma.objects.get(id=lemma_id, old=False) |
75 | - lexical_units = LexicalUnit.objects.filter(Q(base__startswith=lemma.entry + u' ')|Q(base__contains=u' '+lemma.entry+u' ')|Q(base__endswith=u' '+lemma.entry)|Q(base=lemma.entry)).order_by('sense') | 77 | + lexical_units = LexicalUnit.objects.filter(Q(base=lemma.entry, pos="czasownik")|Q(base=lemma.entry+u' się', pos="czasownik")).order_by('sense') |
78 | +# lexical_units = LexicalUnit.objects.filter(Q(base__startswith=lemma.entry + u' ')|Q(base__contains=u' '+lemma.entry+u' ')|Q(base__endswith=u' '+lemma.entry)|Q(base=lemma.entry)).order_by('sense') | ||
76 | 79 | ||
77 | alternations = {} | 80 | alternations = {} |
78 | frames_dict = {} | 81 | frames_dict = {} |
@@ -205,16 +208,29 @@ def ajax_frames(request, lemma_id): | @@ -205,16 +208,29 @@ def ajax_frames(request, lemma_id): | ||
205 | @ajax(method='get', encode_result=False) | 208 | @ajax(method='get', encode_result=False) |
206 | def ajax_units(request, lemma_id): | 209 | def ajax_units(request, lemma_id): |
207 | lemma = Lemma.objects.get(id=lemma_id, old=False) | 210 | lemma = Lemma.objects.get(id=lemma_id, old=False) |
208 | -# lexical_units = LexicalUnit.objects.filter(Q(base = lemma.entry, pos="czasownik")|Q(base = lemma.entry + u' się', pos="czasownik")).order_by('base', 'sense') | ||
209 | - 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') | 211 | + lexical_units = LexicalUnit.objects.filter(Q(base = lemma.entry, pos="czasownik")|Q(base = lemma.entry + u' się', pos="czasownik")).order_by('base', 'sense') |
212 | +# 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') | ||
210 | 213 | ||
211 | context = { | 214 | context = { |
212 | - 'lexical_units': [{"id": lu.id, "luid": lu.luid, "base": lu.base, "sense": lu.sense, "pos": lu.pos, "glossa": lu.glossa, "definition": lu.definition} for lu in lexical_units], | 215 | + '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], |
213 | '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ę' | 216 | '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ę' |
214 | } | 217 | } |
215 | 218 | ||
216 | return context | 219 | return context |
217 | 220 | ||
221 | +def location(lexical_unit): | ||
222 | + if lexical_unit.synset is None: | ||
223 | + return "" | ||
224 | + if lexical_unit.luid >= 0: | ||
225 | + return "" | ||
226 | + where = Synonymy.objects.filter(parent=lexical_unit.synset) | ||
227 | + if len(where) > 0: | ||
228 | + return "synonim " + unicode(where[0].child) | ||
229 | + where = Hypernymy.objects.filter(parent=lexical_unit.synset) | ||
230 | + if len(where) > 0: | ||
231 | + return "hiponim " + unicode(where[0].child) | ||
232 | + return "nieznana lokacja w Słowosieci" | ||
233 | + | ||
218 | @ajax(method='get') | 234 | @ajax(method='get') |
219 | def ajax_predefined_preferences(request): | 235 | def ajax_predefined_preferences(request): |
220 | predefined = [] | 236 | predefined = [] |