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 | 64 | u += '\n'; |
65 | 65 | } |
66 | 66 | u += lexical_units[lid].definition; |
67 | + if (lexical_units[lid].definition != '') { | |
68 | + u += '\n'; | |
69 | + } | |
70 | + u += lexical_units[lid].location; | |
67 | 71 | u +='"> '; |
68 | 72 | u += lexical_units[lid].base + '-' + lexical_units[lid].sense; |
69 | 73 | u += '</strong>'; |
... | ... |
semantics/static/js/semantics_lexical_units.js
... | ... | @@ -34,7 +34,7 @@ function createLexicalUnit(refl, glossa, relation, to) { |
34 | 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 | 38 | var operation = {operation: 'add_unit', unit:lu}; |
39 | 39 | lexical_units.push(lu); |
40 | 40 | lexical_unit_examples[free_luid] = [] |
... | ... | @@ -88,6 +88,15 @@ function setGlossa(luid, glossa) { |
88 | 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 | 100 | // save all changes to meanings (lexical units) |
92 | 101 | function saveMeanings() { |
93 | 102 | $.ajax({ |
... | ... | @@ -119,7 +128,15 @@ function getMeanings() { |
119 | 128 | |
120 | 129 | var i; |
121 | 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 | 142 | return display; |
... | ... |
semantics/static/js/semantics_view.js
... | ... | @@ -767,6 +767,7 @@ function frameClick(clicked_id) { |
767 | 767 | $('#assign_role').attr('disabled', "True"); |
768 | 768 | $('#add_preference').attr('disabled', "True"); |
769 | 769 | $('#delete').attr('disabled', "True"); |
770 | + $('#multi_lus').attr('disabled', "True"); | |
770 | 771 | $('#change_lus').attr('disabled', "True"); |
771 | 772 | $('#change_opinion').attr('disabled', "True"); |
772 | 773 | } else { |
... | ... | @@ -778,6 +779,7 @@ function frameClick(clicked_id) { |
778 | 779 | $('#assign_role').attr('disabled', "True"); |
779 | 780 | $('#add_preference').attr('disabled', "True"); |
780 | 781 | $('#delete').removeAttr('disabled'); |
782 | + $('#multi_lus').removeAttr('disabled'); | |
781 | 783 | $('#change_lus').removeAttr('disabled'); |
782 | 784 | $('#change_opinion').removeAttr('disabled'); |
783 | 785 | } |
... | ... | @@ -795,6 +797,7 @@ function frameClick(clicked_id) { |
795 | 797 | $('#assign_role').attr('disabled', "True"); |
796 | 798 | $('#add_preference').attr('disabled', "True"); |
797 | 799 | $('#delete').attr('disabled', "True"); |
800 | + $('#multi_lus').attr('disabled', "True"); | |
798 | 801 | $('#change_lus').attr('disabled', "True"); |
799 | 802 | $('#change_opinion').attr('disabled', "True"); |
800 | 803 | } else { |
... | ... | @@ -812,6 +815,7 @@ function frameClick(clicked_id) { |
812 | 815 | $('#assign_role').removeAttr('disabled'); |
813 | 816 | $('#add_preference').removeAttr('disabled'); |
814 | 817 | $('#delete').removeAttr('disabled'); |
818 | + $('#multi_lus').removeAttr('disabled'); | |
815 | 819 | $('#change_lus').removeAttr('disabled'); |
816 | 820 | $('#change_opinion').removeAttr('disabled'); |
817 | 821 | } |
... | ... |
semantics/templates/semantics.html
... | ... | @@ -99,6 +99,8 @@ |
99 | 99 | <button type="button" onclick="createFrame()" id="create_frame">Nowa rama</button> |
100 | 100 | <button type="button" onclick="removeFromFrame()" id="delete" disabled="True">Usuń</button> |
101 | 101 | <br/> |
102 | + <button type="button" onclick="changeLexicalUnits()" id="multi_lus" disabled="True">Jednostki wielowyrazowe</button> | |
103 | + <br/> | |
102 | 104 | <button type="button" onclick="changeLexicalUnits()" id="change_lus" disabled="True">Zmień jednostki</button> |
103 | 105 | <button type="button" onclick="changeOpinion()" id="change_opinion" disabled="True">Ustaw ocenę</button> |
104 | 106 | <br/> |
... | ... |
semantics/views.py
... | ... | @@ -3,7 +3,9 @@ |
3 | 3 | from semantics.models import SemanticRole, SemanticFrame, Complement, \ |
4 | 4 | LexicalUnit, FrameRankings, SemanticRolesDisplay, \ |
5 | 5 | LexicalUnitExamples, SelectivePreferenceRelations, \ |
6 | - GeneralSelectivePreference, FrameOpinion | |
6 | + GeneralSelectivePreference, FrameOpinion, Synset | |
7 | + | |
8 | +from wordnet.models import Hypernymy, Synonymy | |
7 | 9 | |
8 | 10 | from dictionary.models import Frame_Char_Model, Lemma, Lemma_Status, \ |
9 | 11 | sort_arguments, sort_positions |
... | ... | @@ -72,7 +74,8 @@ def reorder_history(frames_list): |
72 | 74 | def ajax_frames(request, lemma_id): |
73 | 75 | |
74 | 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 | 80 | alternations = {} |
78 | 81 | frames_dict = {} |
... | ... | @@ -205,16 +208,29 @@ def ajax_frames(request, lemma_id): |
205 | 208 | @ajax(method='get', encode_result=False) |
206 | 209 | def ajax_units(request, lemma_id): |
207 | 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 | 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 | 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 | 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 | 234 | @ajax(method='get') |
219 | 235 | def ajax_predefined_preferences(request): |
220 | 236 | predefined = [] |
... | ... |