Commit 8671b45052c18cf46fbec5fffa7eb266afa57192
1 parent
6b16d0dc
phraseology -- second attempt on interface
Showing
5 changed files
with
184 additions
and
71 deletions
semantics/static/js/semantics_frames.js
@@ -93,6 +93,12 @@ function getFrameDisplay(frame_description){ | @@ -93,6 +93,12 @@ function getFrameDisplay(frame_description){ | ||
93 | display += '<table class="InactiveFrameTable">'; | 93 | display += '<table class="InactiveFrameTable">'; |
94 | display += '<tr><td class="ColumnHeader">Rama:</td><td id="frame_' + frame_description.frame_id + '_" class="frame_' + frame_description.frame_id + '_" colspan="' + frame_description.colspan + '" onclick="frameClick(\'frame_' + frame_description.frame_id + '_\', \'frame_' + frame_description.frame_id + '_\')">'; | 94 | display += '<tr><td class="ColumnHeader">Rama:</td><td id="frame_' + frame_description.frame_id + '_" class="frame_' + frame_description.frame_id + '_" colspan="' + frame_description.colspan + '" onclick="frameClick(\'frame_' + frame_description.frame_id + '_\', \'frame_' + frame_description.frame_id + '_\')">'; |
95 | display += '<span class="Opinion">' + frame_description.status + ' [' + frame_description.frame_id + ']</span>'; | 95 | display += '<span class="Opinion">' + frame_description.status + ' [' + frame_description.frame_id + ']</span>'; |
96 | + // display += '</td>'; | ||
97 | + if (frame_description.lemma.include) { | ||
98 | + display += '<table style="float: right"><td id="' + frame_description.lemma.csv_id + '" class="' + frame_description.lemma.csv_class + '" onclick="var e = arguments[0]; e.stopPropagation(); frameClick(\'' +frame_description.lemma.csv_id + '\', \'' + frame_description.lemma.csv_class + '\')">Lemma</td></table>'; | ||
99 | + } | ||
100 | + display += '</td>'; | ||
101 | + display += '</tr>'; | ||
96 | display += '<tr>'; | 102 | display += '<tr>'; |
97 | display += '<td class="ColumnHeader">Rola:</td>'; | 103 | display += '<td class="ColumnHeader">Rola:</td>'; |
98 | for (i = 0; i < frame_description.display.roles.length; i++) { | 104 | for (i = 0; i < frame_description.display.roles.length; i++) { |
@@ -155,7 +161,7 @@ function newFrame(units) { | @@ -155,7 +161,7 @@ function newFrame(units) { | ||
155 | } | 161 | } |
156 | lexical_units_num.push(units_list); | 162 | lexical_units_num.push(units_list); |
157 | 163 | ||
158 | - frame_content[free_frame_id] = {colspan: "1", rowspan: "1", status: "brak", frame_id: "" + x, display: {preferences:[[]], roles:[]}}; | 164 | + frame_content[free_frame_id] = {colspan: "1", rowspan: "1", status: "brak", frame_id: "" + x, display: {preferences:[[]], roles:[]}, lemma: {include: false}}; |
159 | frames_operations.push({operation: "create_frame", meanings: units_list, id: x}); | 165 | frames_operations.push({operation: "create_frame", meanings: units_list, id: x}); |
160 | free_frame_id = free_frame_id - 1; | 166 | free_frame_id = free_frame_id - 1; |
161 | } | 167 | } |
@@ -240,13 +246,30 @@ function roleFree(frame_id, field_ids) { | @@ -240,13 +246,30 @@ function roleFree(frame_id, field_ids) { | ||
240 | function addArgument(frame_id, field_ids, roles) { | 246 | function addArgument(frame_id, field_ids, roles) { |
241 | 247 | ||
242 | if (validateRoles(roles)) { | 248 | if (validateRoles(roles)) { |
243 | - frame_content[frame_id].colspan = "" + (parseInt(frame_content[frame_id].colspan) + 1); | ||
244 | - frame_content[frame_id].display.roles.push({csv_class: 'frame_' + frame_id + '_comp_' + free_complement_id + '_', csv_id: 'frame_' + frame_id + '_comp_' + free_complement_id + '_', argument: ''}); | ||
245 | - var i; | ||
246 | - for (i = 0; i < frame_content[frame_id].rowspan; i++) { | ||
247 | - frame_content[frame_id].display.preferences[i].push({csv_class: 'frame_' + frame_id + '_comp_' + free_complement_id + '_', csv_id: 'frame_' + frame_id + '_comp_' + free_complement_id + '_pref_-' + i + '_', preference: ''}); | 249 | + if (isLemma(roles)) { |
250 | + if (frame_content[frame_id].lemma.include) { | ||
251 | + alert("Ta rama ma już pole związane z lematem!"); | ||
252 | + } else { | ||
253 | + frame_content[frame_id].lemma = {include: true, csv_class: 'frame_' + frame_id + '_lemma_comp_' + free_complement_id + '_', csv_id: 'frame_' + frame_id + '_lemma_comp_' + free_complement_id + '_'}; | ||
254 | + connected['frame_' + frame_id + '_lemma_comp_' + free_complement_id + '_'] = field_ids; | ||
255 | + var complement_id_num = free_complement_id; | ||
256 | + free_complement_id = free_complement_id - 1; | ||
257 | + var complement_id = "frame_" + highlighted_id + "_lemma_comp_" + complement_id_num + "_"; | ||
258 | + var conn_complement_id = "frame_" + highlighted_id + "_comp_" + complement_id_num + "_"; | ||
259 | + } | ||
260 | + } else { | ||
261 | + frame_content[frame_id].colspan = "" + (parseInt(frame_content[frame_id].colspan) + 1); | ||
262 | + frame_content[frame_id].display.roles.push({csv_class: 'frame_' + frame_id + '_comp_' + free_complement_id + '_', csv_id: 'frame_' + frame_id + '_comp_' + free_complement_id + '_', argument: ''}); | ||
263 | + var i; | ||
264 | + for (i = 0; i < frame_content[frame_id].rowspan; i++) { | ||
265 | + frame_content[frame_id].display.preferences[i].push({csv_class: 'frame_' + frame_id + '_comp_' + free_complement_id + '_', csv_id: 'frame_' + frame_id + '_comp_' + free_complement_id + '_pref_-' + i + '_', preference: ''}); | ||
266 | + } | ||
267 | + connected['frame_' + frame_id + '_comp_' + free_complement_id + '_'] = field_ids; | ||
268 | + var complement_id_num = free_complement_id; | ||
269 | + free_complement_id = free_complement_id - 1; | ||
270 | + var complement_id = "frame_" + highlighted_id + "_comp_" + complement_id_num + "_"; | ||
271 | + var conn_complement_id = complement_id; | ||
248 | } | 272 | } |
249 | - connected['frame_' + frame_id + '_comp_' + free_complement_id + '_'] = field_ids; | ||
250 | 273 | ||
251 | for(i = 0; i < field_ids.length; i++) { | 274 | for(i = 0; i < field_ids.length; i++) { |
252 | if (typeof(connected_reverse[field_ids[i]]) == 'undefined') { | 275 | if (typeof(connected_reverse[field_ids[i]]) == 'undefined') { |
@@ -254,44 +277,46 @@ function addArgument(frame_id, field_ids, roles) { | @@ -254,44 +277,46 @@ function addArgument(frame_id, field_ids, roles) { | ||
254 | } | 277 | } |
255 | connected_reverse[field_ids[i]].push('frame_' + frame_id + '_'); | 278 | connected_reverse[field_ids[i]].push('frame_' + frame_id + '_'); |
256 | } | 279 | } |
257 | - | ||
258 | - var complement_id = free_complement_id; | ||
259 | - free_complement_id = free_complement_id - 1; | ||
260 | 280 | ||
261 | for (i = 0; i < frame_content[frame_id].display.roles.length; i++) { | 281 | for (i = 0; i < frame_content[frame_id].display.roles.length; i++) { |
262 | - if (frame_content[frame_id].display.roles[i].csv_id == 'frame_' + frame_id + '_comp_' + complement_id + '_') { | 282 | + if (frame_content[frame_id].display.roles[i].csv_id == complement_id) { |
263 | frame_content[frame_id].display.roles[i].argument = roles; | 283 | frame_content[frame_id].display.roles[i].argument = roles; |
264 | } | 284 | } |
265 | } | 285 | } |
266 | 286 | ||
267 | - frames_operations.push({operation: 'add_argument', frame_id: frame_id, id: complement_id, role: roles}); | 287 | + frames_operations.push({operation: 'add_argument', frame_id: frame_id, id: complement_id_num, role: roles}); |
268 | for (i = 0; i < field_ids.length; i++) { | 288 | for (i = 0; i < field_ids.length; i++) { |
269 | - frames_operations.push({operation: 'connect', arg: 'frame_' + frame_id + '_comp_' + complement_id + '_', connect: field_ids[i]}); | 289 | + frames_operations.push({operation: 'connect', arg: conn_complement_id, connect: field_ids[i]}); |
270 | } | 290 | } |
271 | 291 | ||
272 | return complement_id; | 292 | return complement_id; |
273 | } else { | 293 | } else { |
294 | + alert("Wybrano niepoprawny zestaw ról!"); | ||
274 | return false; | 295 | return false; |
275 | } | 296 | } |
276 | 297 | ||
277 | } | 298 | } |
278 | 299 | ||
279 | -function removeArgument(frame_id, complement_id) { | 300 | +function removeArgument(frame_id, complement_id, argument) { |
280 | var pos = -1; | 301 | var pos = -1; |
281 | - var arg = "frame_" + frame_id + "_comp_" + complement_id + "_" | 302 | + var arg = argument; |
282 | 303 | ||
283 | - var i; | ||
284 | - for (i = 0; i < frame_content[frame_id].display.roles.length; i++) { | ||
285 | - if (frame_content[frame_id].display.roles[i].csv_id == arg) { | ||
286 | - pos = i; | ||
287 | - } | ||
288 | - } | ||
289 | - | ||
290 | - frame_content[frame_id].display.roles.splice(pos, 1); | ||
291 | - | ||
292 | - var j; | ||
293 | - for (j = 0; j < frame_content[frame_id].display.preferences.length; j++) { | ||
294 | - frame_content[frame_id].display.preferences[j].splice(pos, 1); | 304 | + if (argument.split('_').length == 5) { // zwykły argument |
305 | + var i; | ||
306 | + for (i = 0; i < frame_content[frame_id].display.roles.length; i++) { | ||
307 | + if (frame_content[frame_id].display.roles[i].csv_id == arg) { | ||
308 | + pos = i; | ||
309 | + } | ||
310 | + } | ||
311 | + | ||
312 | + frame_content[frame_id].display.roles.splice(pos, 1); | ||
313 | + | ||
314 | + var j; | ||
315 | + for (j = 0; j < frame_content[frame_id].display.preferences.length; j++) { | ||
316 | + frame_content[frame_id].display.preferences[j].splice(pos, 1); | ||
317 | + } | ||
318 | + } else { // argument leksykalny | ||
319 | + frame_content[frame_id].lemma.include = false; | ||
295 | } | 320 | } |
296 | 321 | ||
297 | frames_operations.push({operation: 'remove_argument', frame_id: frame_id, complement_id: complement_id}); | 322 | frames_operations.push({operation: 'remove_argument', frame_id: frame_id, complement_id: complement_id}); |
@@ -462,12 +487,16 @@ function saveFrames() { | @@ -462,12 +487,16 @@ function saveFrames() { | ||
462 | else { | 487 | else { |
463 | frameClick(""); | 488 | frameClick(""); |
464 | $.post(ajax_modify_frames, {"operations": JSON.stringify(frames_operations), "lemma_id": lemma_id}, function(data){ | 489 | $.post(ajax_modify_frames, {"operations": JSON.stringify(frames_operations), "lemma_id": lemma_id}, function(data){ |
465 | - getFrames(data.frames_display); | ||
466 | - displayFrames(); | ||
467 | - memorizeConnections(data.connections.connected, data.connections.connected_reverse); | ||
468 | - $("#semantic-frames-count").empty(); | ||
469 | - $("#semantic-frames-count").append(data.frames_count); | ||
470 | - updateSchemataConnections(); | 490 | + $.getJSON(ajax_units, {"lemma_id": window.lemma_id}, function(units) { |
491 | + memorizeLexicalUnits(units.lexical_units); | ||
492 | + basicLexicalUnitsData(units.informations); | ||
493 | + getFrames(data.frames_display); | ||
494 | + displayFrames(); | ||
495 | + memorizeConnections(data.connections.connected, data.connections.connected_reverse); | ||
496 | + $("#semantic-frames-count").empty(); | ||
497 | + $("#semantic-frames-count").append(data.frames_count); | ||
498 | + updateSchemataConnections(); | ||
499 | + }); | ||
471 | }, 'json'); | 500 | }, 'json'); |
472 | frames_operations = []; | 501 | frames_operations = []; |
473 | } | 502 | } |
semantics/static/js/semantics_lexical_units.js
@@ -198,34 +198,31 @@ function getMeaningsSelectionForFrame(frame_id) { | @@ -198,34 +198,31 @@ function getMeaningsSelectionForFrame(frame_id) { | ||
198 | 198 | ||
199 | display += "<div>"; | 199 | display += "<div>"; |
200 | 200 | ||
201 | - var i; | ||
202 | - var roles = frame_content[frame_id].display.roles; | ||
203 | - for (i = 0; i < roles.length; i++) { | ||
204 | - if (isPOL(frame_id, i)) { | ||
205 | - var j; | ||
206 | - for (j = 0; j < connected[roles[i].csv_class].length; j++) { | ||
207 | - var options = []; | ||
208 | - var sch = connected[roles[i].csv_class][j].split("pos")[0]; | ||
209 | - var pos = connected[roles[i].csv_class][j].split("arg")[0]; | ||
210 | - var k; | ||
211 | - for (k = 0; k < schemas_content[sch].display.arguments[0].length; k++) { | ||
212 | - if (schemas_content[sch].display.arguments[0][k].csv_class == pos) { | ||
213 | - var l; | ||
214 | - for (l = 0; l < schemas_content[sch].display.arguments[0][k].lex.length; l++) { | ||
215 | - options.push(schemas_content[sch].display.arguments[0][k].lex[l]); | ||
216 | - } | ||
217 | - } | ||
218 | - } | ||
219 | - var temp; // TODO: temporal solution for multiple schemata | ||
220 | - if (hasRefl(sch)) { | ||
221 | - temp = [['się'], options] | ||
222 | - } else { | ||
223 | - temp = [options]; | ||
224 | - } | ||
225 | - lexicalisation.push(temp); | ||
226 | - } | 201 | + if (frame_content[frame_id].lemma.include) { |
202 | + var lem = frame_content[frame_id].lemma.csv_class; | ||
203 | + var j; | ||
204 | + for (j = 0; j < connected[lem].length; j++) { | ||
205 | + var options = []; | ||
206 | + var sch = connected[lem][j].split("pos")[0]; | ||
207 | + var pos = connected[lem][j].split("arg")[0]; | ||
208 | + var k; | ||
209 | + for (k = 0; k < schemas_content[sch].display.arguments[0].length; k++) { | ||
210 | + if (schemas_content[sch].display.arguments[0][k].csv_class == pos) { | ||
211 | + var l; | ||
212 | + for (l = 0; l < schemas_content[sch].display.arguments[0][k].lex.length; l++) { | ||
213 | + options.push(schemas_content[sch].display.arguments[0][k].lex[l]); | ||
214 | + } | ||
215 | + } | ||
216 | + } | ||
217 | + var temp; // TODO: temporal solution for multiple schemata | ||
218 | + if (hasRefl(sch)) { | ||
219 | + temp = [['się'], options] | ||
220 | + } else { | ||
221 | + temp = [options]; | ||
222 | + } | ||
223 | + lexicalisation.push(temp); | ||
227 | } | 224 | } |
228 | - } | 225 | + } |
229 | 226 | ||
230 | display += getFormForLexicalisation(lexicalisation); | 227 | display += getFormForLexicalisation(lexicalisation); |
231 | 228 | ||
@@ -293,6 +290,12 @@ function lexicalisationForm(tokenised) { | @@ -293,6 +290,12 @@ function lexicalisationForm(tokenised) { | ||
293 | var display = ""; | 290 | var display = ""; |
294 | var i; | 291 | var i; |
295 | for (i = 0; i < tokenised.length; i++) { | 292 | for (i = 0; i < tokenised.length; i++) { |
293 | + var j; | ||
294 | + for (j = 0; j < lexical_units.length; j++) { | ||
295 | + if (base + " " + tokenised[i].join(" ") == lexical_units[j].base) { | ||
296 | + return ""; | ||
297 | + } | ||
298 | + } | ||
296 | display += "<input type = \"checkbox\" name = \"mwe\" value = \"" + base + " " + tokenised[i].join(" ") + "\">"; // TODO: unikalne wartości, wartość => dodanie odpowiedniej jednostki (nazwa jednostki w wartości?) | 299 | display += "<input type = \"checkbox\" name = \"mwe\" value = \"" + base + " " + tokenised[i].join(" ") + "\">"; // TODO: unikalne wartości, wartość => dodanie odpowiedniej jednostki (nazwa jednostki w wartości?) |
297 | display += base + " " + tokenised[i].join(" ") + "<br\>"; | 300 | display += base + " " + tokenised[i].join(" ") + "<br\>"; |
298 | } | 301 | } |
semantics/static/js/semantics_roles.js
@@ -45,6 +45,13 @@ function rolesToHtml(roles_display, full){ | @@ -45,6 +45,13 @@ function rolesToHtml(roles_display, full){ | ||
45 | return table; | 45 | return table; |
46 | } | 46 | } |
47 | 47 | ||
48 | +function isLemma(roles) { | ||
49 | + if (roles.length != 1) { | ||
50 | + return false; | ||
51 | + } | ||
52 | + return (role_name[roles[0]] == 'Lemma'); | ||
53 | +} | ||
54 | + | ||
48 | function memorizeRoles(roles_display, roles_full){ | 55 | function memorizeRoles(roles_display, roles_full){ |
49 | roles_display_table = rolesToHtml(roles_display, false); | 56 | roles_display_table = rolesToHtml(roles_display, false); |
50 | roles_display_table_full = rolesToHtml(roles_full, true); | 57 | roles_display_table_full = rolesToHtml(roles_full, true); |
semantics/static/js/semantics_view.js
@@ -769,7 +769,7 @@ function removeFromFrame() { | @@ -769,7 +769,7 @@ function removeFromFrame() { | ||
769 | 769 | ||
770 | } | 770 | } |
771 | if (op == "add_realization") { | 771 | if (op == "add_realization") { |
772 | - // arg = "frame_26_comp_36_" | 772 | + // arg = "frame_26_comp_36_(lemma_)" |
773 | 773 | ||
774 | var frame_id = parseInt(arg.split('_')[1]); | 774 | var frame_id = parseInt(arg.split('_')[1]); |
775 | var complement_id = parseInt(arg.split('_')[3]); | 775 | var complement_id = parseInt(arg.split('_')[3]); |
@@ -777,8 +777,8 @@ function removeFromFrame() { | @@ -777,8 +777,8 @@ function removeFromFrame() { | ||
777 | var h = "frame_" + highlighted_id + "_"; | 777 | var h = "frame_" + highlighted_id + "_"; |
778 | 778 | ||
779 | frameClick(h); | 779 | frameClick(h); |
780 | - | ||
781 | - removeArgument(frame_id, complement_id); | 780 | + |
781 | + removeArgument(frame_id, complement_id, arg); | ||
782 | 782 | ||
783 | op = "add_argument"; | 783 | op = "add_argument"; |
784 | arg = ""; | 784 | arg = ""; |
@@ -812,7 +812,7 @@ function removeFromFrame() { | @@ -812,7 +812,7 @@ function removeFromFrame() { | ||
812 | //////////////////////////// Display //////////////////////////// | 812 | //////////////////////////// Display //////////////////////////// |
813 | 813 | ||
814 | function frameClick(clicked_id) { | 814 | function frameClick(clicked_id) { |
815 | - | 815 | + |
816 | if (clicked_id == "") { | 816 | if (clicked_id == "") { |
817 | deselect(); | 817 | deselect(); |
818 | highlighted_id = ""; | 818 | highlighted_id = ""; |
@@ -866,6 +866,38 @@ function frameClick(clicked_id) { | @@ -866,6 +866,38 @@ function frameClick(clicked_id) { | ||
866 | $('#change_lus').removeAttr('disabled'); | 866 | $('#change_lus').removeAttr('disabled'); |
867 | $('#change_opinion').removeAttr('disabled'); | 867 | $('#change_opinion').removeAttr('disabled'); |
868 | } | 868 | } |
869 | + } else if (clicked_id.split('_')[4] == 'lemma') { // part of lemma click | ||
870 | + frame_id = clicked_id.split('_')[1] | ||
871 | + | ||
872 | + if (highlighted_id != "") { | ||
873 | + deselect(); | ||
874 | + } | ||
875 | + if (semantics_selected_id == clicked_id) { | ||
876 | + highlighted_id = ""; | ||
877 | + semantics_selected_id = ""; | ||
878 | + op = "none"; | ||
879 | + | ||
880 | + $('#assign_role').attr('disabled', "True"); | ||
881 | + $('#add_preference').attr('disabled', "True"); | ||
882 | + $('#delete').attr('disabled', "True"); | ||
883 | + $('#multi_lus').attr('disabled', "True"); | ||
884 | + $('#change_lus').attr('disabled', "True"); | ||
885 | + $('#change_opinion').attr('disabled', "True"); | ||
886 | + } else { | ||
887 | + select(frame_id, clicked_id); | ||
888 | + | ||
889 | + highlighted_id = frame_id; | ||
890 | + semantics_selected_id = clicked_id; | ||
891 | + op = "add_realization"; | ||
892 | + arg = clicked_id //.split('pref')[0] | ||
893 | + | ||
894 | + $('#assign_role').attr('disabled', "True"); | ||
895 | + $('#add_preference').attr('disabled', "True"); | ||
896 | + $('#delete').removeAttr('disabled'); | ||
897 | + $('#multi_lus').removeAttr('disabled'); | ||
898 | + $('#change_lus').removeAttr('disabled'); | ||
899 | + $('#change_opinion').removeAttr('disabled'); | ||
900 | + } | ||
869 | } else { // argument click | 901 | } else { // argument click |
870 | frame_id = clicked_id.split('_')[1] | 902 | frame_id = clicked_id.split('_')[1] |
871 | 903 | ||
@@ -947,6 +979,19 @@ function selectFrame(frame_id, clicked_id) { | @@ -947,6 +979,19 @@ function selectFrame(frame_id, clicked_id) { | ||
947 | $('#' + functionCsvId(connected[roles[i].csv_class][j])).css('color', ''); | 979 | $('#' + functionCsvId(connected[roles[i].csv_class][j])).css('color', ''); |
948 | } | 980 | } |
949 | } | 981 | } |
982 | + | ||
983 | + var lemma = frame_content[frame_id].lemma; | ||
984 | + if (lemma.include) { | ||
985 | + var style = {type: 'background-color', value: 'white'}; | ||
986 | + $('#' + lemma.csv_id).css(style.type, style.value); | ||
987 | + var j; | ||
988 | + for (j = 0; j < connected[lemma.csv_class].length; j++) { | ||
989 | + $('#' + connected[lemma.csv_class][j]).css(style.type, style.value); | ||
990 | + $('#' + connected[lemma.csv_class][j]).css('color', ''); | ||
991 | + $('#' + functionCsvId(connected[lemma.csv_class][j])).css(style.type, style.value); | ||
992 | + $('#' + functionCsvId(connected[lemma.csv_class][j])).css('color', ''); | ||
993 | + } | ||
994 | + } | ||
950 | 995 | ||
951 | $("#" + clicked_id).css('border-width', '5px'); | 996 | $("#" + clicked_id).css('border-width', '5px'); |
952 | 997 | ||
@@ -1119,7 +1164,7 @@ function schemaClick(class_id, lex) { | @@ -1119,7 +1164,7 @@ function schemaClick(class_id, lex) { | ||
1119 | } | 1164 | } |
1120 | field_ids = [class_id]; | 1165 | field_ids = [class_id]; |
1121 | } | 1166 | } |
1122 | - | 1167 | + |
1123 | if (control == "connect") { | 1168 | if (control == "connect") { |
1124 | if (op == "none") { | 1169 | if (op == "none") { |
1125 | return; | 1170 | return; |
@@ -1153,7 +1198,7 @@ function schemaClick(class_id, lex) { | @@ -1153,7 +1198,7 @@ function schemaClick(class_id, lex) { | ||
1153 | 1198 | ||
1154 | if (complement_id) { | 1199 | if (complement_id) { |
1155 | var h = "frame_" + highlighted_id + "_"; | 1200 | var h = "frame_" + highlighted_id + "_"; |
1156 | - var a = "frame_" + highlighted_id + "_comp_" + complement_id + "_"; | 1201 | + var a = complement_id; //"frame_" + highlighted_id + "_comp_" + complement_id + "_"; |
1157 | 1202 | ||
1158 | // re-draw and re-color frame | 1203 | // re-draw and re-color frame |
1159 | frameClick(h); | 1204 | frameClick(h); |
@@ -1162,9 +1207,9 @@ function schemaClick(class_id, lex) { | @@ -1162,9 +1207,9 @@ function schemaClick(class_id, lex) { | ||
1162 | 1207 | ||
1163 | result = true; | 1208 | result = true; |
1164 | $.prompt.close(); | 1209 | $.prompt.close(); |
1165 | - } else { | 1210 | + } /*else { |
1166 | alert("Wybrano niepoprawne role!"); | 1211 | alert("Wybrano niepoprawne role!"); |
1167 | - } | 1212 | + } */ |
1168 | } | 1213 | } |
1169 | 1214 | ||
1170 | } | 1215 | } |
@@ -1188,7 +1233,11 @@ function schemaClick(class_id, lex) { | @@ -1188,7 +1233,11 @@ function schemaClick(class_id, lex) { | ||
1188 | if (arg == "") { | 1233 | if (arg == "") { |
1189 | return; | 1234 | return; |
1190 | } else { | 1235 | } else { |
1191 | - // arg = "frame_26_comp_36_" | 1236 | + // arg = "frame_26_comp_36_(lemma_)" |
1237 | + if (arg.split('_')[4] == 'lemma' && lex.length == 0) { | ||
1238 | + alert("Nie można podłączyć do lematu!"); | ||
1239 | + return; | ||
1240 | + } | ||
1192 | var frame_id = parseInt(parseInt(arg.split('_')[1])); | 1241 | var frame_id = parseInt(parseInt(arg.split('_')[1])); |
1193 | var i, j; | 1242 | var i, j; |
1194 | var can_connect = false; | 1243 | var can_connect = false; |
semantics/views.py
@@ -115,7 +115,10 @@ def create_frames_context(lemma_id, user): | @@ -115,7 +115,10 @@ def create_frames_context(lemma_id, user): | ||
115 | frame_display["lexical_units"].append({"id": str(lu.id), "base": lu.base, "sense": str(lu.sense)}) | 115 | frame_display["lexical_units"].append({"id": str(lu.id), "base": lu.base, "sense": str(lu.sense)}) |
116 | for frame in type_frames[t]: | 116 | for frame in type_frames[t]: |
117 | # frame_complements = Complement.objects.filter(frame=frame) | 117 | # frame_complements = Complement.objects.filter(frame=frame) |
118 | - frame_complements = frame.complements.all() | 118 | + # frame_complements = frame.complements.all() |
119 | + lemma_role = SemanticRole.objects.get(role="Lemma") | ||
120 | + frame_complements = frame.complements.all().exclude(roles=lemma_role) | ||
121 | + lemma_argument = frame.complements.filter(roles=lemma_role) | ||
119 | 122 | ||
120 | # classes and first frame/position part of identifiers | 123 | # classes and first frame/position part of identifiers |
121 | frame_ids = [u'frame_' + str(frame.id) + '_comp_' + str(complement.id) + '_' for complement in frame_complements] | 124 | frame_ids = [u'frame_' + str(frame.id) + '_comp_' + str(complement.id) + '_' for complement in frame_complements] |
@@ -174,7 +177,29 @@ def create_frames_context(lemma_id, user): | @@ -174,7 +177,29 @@ def create_frames_context(lemma_id, user): | ||
174 | status = u'pewna' | 177 | status = u'pewna' |
175 | else: | 178 | else: |
176 | status = frame.opinion.value | 179 | status = frame.opinion.value |
177 | - frame_display["frames"].append({"frame_id": str(frame.id), "colspan": str(max(len(frame_roles), 1)), "rowspan": str(frame_preferences_rowspan), "status": status, "display": display}) | 180 | + if len(lemma_argument) > 0: |
181 | + csv = u'frame_' + str(frame.id) + '_comp_' + str(lemma_argument[0].id) + '_lemma_' | ||
182 | + lemma_info = {"include": True, "csv_id": csv, "csv_class": csv} | ||
183 | + if csv not in complement_arguments: | ||
184 | + complement_arguments[csv] = [] | ||
185 | + | ||
186 | + for schema_position in lemma_argument[0].realizations.all(): | ||
187 | + schema = schema_position.frame | ||
188 | + position = schema_position.position | ||
189 | + argument = schema_position.argument | ||
190 | + alternation = schema_position.alternation | ||
191 | + realization_id = u'schema_' + str(schema.id) + u'_pos_' + str(position.id) + '_arg_' + str(argument.id) + '_' + 'alt_' + str(alternation) + '_' | ||
192 | + complement_arguments[csv].append(realization_id) | ||
193 | + if realization_id not in arguments_frame_connected: | ||
194 | + arguments_frame_connected[realization_id] = [] | ||
195 | + arguments_frame_connected[realization_id].append('frame_' + str(frame.id) + '_') | ||
196 | + if schema.id in alternations[frame.id]: | ||
197 | + alternations[frame.id][schema.id] = max(alternations[frame.id][schema.id], alternation) | ||
198 | + else: | ||
199 | + alternations[frame.id][schema.id] = alternation | ||
200 | + else: | ||
201 | + lemma_info = {"include": False} | ||
202 | + frame_display["frames"].append({"frame_id": str(frame.id), "colspan": str(max(len(frame_roles), 1)), "rowspan": str(frame_preferences_rowspan), "status": status, "display": display, "lemma": lemma_info}) | ||
178 | 203 | ||
179 | for complement, complement_class in zip(frame_complements, frame_ids): | 204 | for complement, complement_class in zip(frame_complements, frame_ids): |
180 | if complement_class not in complement_arguments: | 205 | if complement_class not in complement_arguments: |