Commit 6df6f35d92dcc69a3e9cb3a13929ce0cd8ffe7e7
1 parent
03d41d9a
semantics/management/commands/POL_role.py
Showing
8 changed files
with
437 additions
and
94 deletions
semantics/saving.py
@@ -15,11 +15,13 @@ def modify_frames(lemma_id, operations, user): | @@ -15,11 +15,13 @@ def modify_frames(lemma_id, operations, user): | ||
15 | make_operations(operations) | 15 | make_operations(operations) |
16 | 16 | ||
17 | def make_operations(operations): | 17 | def make_operations(operations): |
18 | - translation = {'frame_id': {}, 'complement_id': {}, 'preference_id': {}} | 18 | + translation = {'unit_id': {}, 'frame_id': {}, 'complement_id': {}, 'preference_id': {}} |
19 | for operation in operations: | 19 | for operation in operations: |
20 | if operation['operation'] == "create_frame": | 20 | if operation['operation'] == "create_frame": |
21 | luids = [int(m['id']) for m in operation['meanings']] | 21 | luids = [int(m['id']) for m in operation['meanings']] |
22 | translation['frame_id'][int(operation['id'])] = create_frame(luids) | 22 | translation['frame_id'][int(operation['id'])] = create_frame(luids) |
23 | + elif operation['operation'] == "add_unit": | ||
24 | + translation['unit_id'][int(operation['unit']['id'])] = add_unit(operation['unit']) | ||
23 | elif operation['operation'] == "remove_frame": | 25 | elif operation['operation'] == "remove_frame": |
24 | if int(operation['id']) in translation['frame_id']: | 26 | if int(operation['id']) in translation['frame_id']: |
25 | frame_id = translation['frame_id'][int(operation['id'])] | 27 | frame_id = translation['frame_id'][int(operation['id'])] |
@@ -91,7 +93,7 @@ def make_operations(operations): | @@ -91,7 +93,7 @@ def make_operations(operations): | ||
91 | frame_id = translation['frame_id'][int(operation['frame_id'])] | 93 | frame_id = translation['frame_id'][int(operation['frame_id'])] |
92 | else: | 94 | else: |
93 | frame_id = int(operation['frame_id']) | 95 | frame_id = int(operation['frame_id']) |
94 | - luids = [int(m) for m in operation['units']] | 96 | + luids = [translation['unit_id'][int(m)] if int(m) in translation['unit_id'] else int(m) for m in operation['units']] |
95 | change_units(frame_id, luids) | 97 | change_units(frame_id, luids) |
96 | elif operation['operation'] == "set_opinion": | 98 | elif operation['operation'] == "set_opinion": |
97 | if int(operation['frame_id']) in translation['frame_id']: | 99 | if int(operation['frame_id']) in translation['frame_id']: |
semantics/static/js/semantics_lexical_units.js
@@ -166,6 +166,9 @@ function getMeaningsSelectionForFrame(frame_id) { | @@ -166,6 +166,9 @@ function getMeaningsSelectionForFrame(frame_id) { | ||
166 | var display = ""; | 166 | var display = ""; |
167 | var id = "" + frame_id; | 167 | var id = "" + frame_id; |
168 | 168 | ||
169 | + | ||
170 | + // podstawowe znaczenia | ||
171 | + display += "<div>"; | ||
169 | var i; | 172 | var i; |
170 | for (i = 0; i < lexical_units.length; i++) { | 173 | for (i = 0; i < lexical_units.length; i++) { |
171 | display += "<input type = \"checkbox\" name = \"meaning\" value = \"" + lexical_units[i].id + "\"" | 174 | display += "<input type = \"checkbox\" name = \"meaning\" value = \"" + lexical_units[i].id + "\"" |
@@ -182,10 +185,118 @@ function getMeaningsSelectionForFrame(frame_id) { | @@ -182,10 +185,118 @@ function getMeaningsSelectionForFrame(frame_id) { | ||
182 | } | 185 | } |
183 | display += ">" + lexical_units[i].base + "-" + lexical_units[i].sense + "<br><div id=\"glossa_" + lexical_units[i].id + "\">" + lexical_units[i].glossa + "</div>" | 186 | display += ">" + lexical_units[i].base + "-" + lexical_units[i].sense + "<br><div id=\"glossa_" + lexical_units[i].id + "\">" + lexical_units[i].glossa + "</div>" |
184 | } | 187 | } |
188 | + display += "</div>"; | ||
189 | + | ||
190 | + // znaczenia wielowyrazowe | ||
191 | + | ||
192 | + var lexicalisation = []; | ||
193 | + | ||
194 | + display += "<br/>"; | ||
195 | + | ||
196 | + display += "<div>"; | ||
197 | + | ||
198 | + var i; | ||
199 | + var roles = frame_content[frame_id].display.roles; | ||
200 | + for (i = 0; i < roles.length; i++) { | ||
201 | + if (isPOL(frame_id, i)) { | ||
202 | + var j; | ||
203 | + for (j = 0; j < connected[roles[i].csv_class].length; j++) { | ||
204 | + var options = []; | ||
205 | + var sch = connected[roles[i].csv_class][j].split("pos")[0]; | ||
206 | + var pos = connected[roles[i].csv_class][j].split("arg")[0]; | ||
207 | + var k; | ||
208 | + for (k = 0; k < schemas_content[sch].display.arguments[0].length; k++) { | ||
209 | + if (schemas_content[sch].display.arguments[0][k].csv_class == pos) { | ||
210 | + var l; | ||
211 | + for (l = 0; l < schemas_content[sch].display.arguments[0][k].lex.length; l++) { | ||
212 | + options.push(schemas_content[sch].display.arguments[0][k].lex[l]); | ||
213 | + } | ||
214 | + } | ||
215 | + } | ||
216 | + var temp; // TODO: temporal solution for multiple schemata | ||
217 | + if (hasRefl(sch)) { | ||
218 | + temp = [['siฤ'], options] | ||
219 | + } else { | ||
220 | + temp = [options]; | ||
221 | + } | ||
222 | + lexicalisation.push(temp); | ||
223 | + } | ||
224 | + } | ||
225 | + } | ||
226 | + | ||
227 | + display += getFormForLexicalisation(lexicalisation); | ||
228 | + | ||
229 | + display += "</div>"; | ||
230 | + | ||
231 | + return display; | ||
232 | +} | ||
233 | + | ||
234 | +function getFormForLexicalisation(lexicalisation) { | ||
235 | + var result = ""; | ||
236 | + var perms = permutations(lexicalisation); | ||
237 | + var i; | ||
238 | + for (i = 0; i < perms.length; i++) { | ||
239 | + result += lexicalisationForm(cartesian(perms[i])); | ||
240 | + } | ||
241 | + return result; | ||
242 | +} | ||
243 | + | ||
244 | +function permutations(llist) { | ||
245 | + return llist; | ||
246 | +/* if (list.length == 0) { | ||
247 | + return [[]]; | ||
248 | + } | ||
249 | + var i; | ||
250 | + var result = []; | ||
251 | + for (i = 0; i < list.length; i++) { | ||
252 | + var shortlist = list.slice(); | ||
253 | + shortlist.splice(i, 1); | ||
254 | + var perms = permutations(shortlist); | ||
255 | + var j; | ||
256 | + for (j = 0; j < perms.length; j++) { | ||
257 | + var tmp = perms[j]; | ||
258 | + tmp.push(list[i]); | ||
259 | + result.push(tmp); | ||
260 | + } | ||
261 | + } | ||
262 | + return result; | ||
263 | +*/ | ||
264 | +} | ||
265 | + | ||
266 | +function cartesian(llist) { | ||
267 | + if (llist.length == 0) { | ||
268 | + return [[]]; | ||
269 | + } | ||
270 | + var result = []; | ||
271 | + var shortllist = llist.slice(); | ||
272 | + shortllist.splice(shortllist.length - 1, 1); | ||
273 | + var carts = cartesian(shortllist); | ||
274 | + var i; | ||
275 | + for (i = 0; i < llist[llist.length - 1].length; i++) { | ||
276 | + var tail = llist[llist.length - 1][i]; | ||
277 | + var heads = carts.slice(); | ||
278 | + var j; | ||
279 | + for (j = 0; j < heads.length; j++) { | ||
280 | + var tmp = heads[j].slice(); | ||
281 | + tmp.push(tail); | ||
282 | + //alert(tmp); | ||
283 | + result.push(tmp); | ||
284 | + } | ||
285 | + } | ||
286 | + return result; | ||
287 | +} | ||
185 | 288 | ||
289 | +function lexicalisationForm(tokenised) { | ||
290 | + var display = ""; | ||
291 | + var i; | ||
292 | + for (i = 0; i < tokenised.length; i++) { | ||
293 | + display += "<input type = \"checkbox\" name = \"mwe\" value = \"" + base + " " + tokenised[i].join(" ") + "\">"; // TODO: unikalne wartoลci, wartoลฤ => dodanie odpowiedniej jednostki (nazwa jednostki w wartoลci?) | ||
294 | + display += base + " " + tokenised[i].join(" ") + "<br\>"; | ||
295 | + } | ||
186 | return display; | 296 | return display; |
187 | } | 297 | } |
188 | 298 | ||
299 | + | ||
189 | // get readable form of lexical unit | 300 | // get readable form of lexical unit |
190 | function getLexicalUnit(luid) { | 301 | function getLexicalUnit(luid) { |
191 | var i = indexOfId(lexical_units, luid); | 302 | var i = indexOfId(lexical_units, luid); |
@@ -193,3 +304,24 @@ function getLexicalUnit(luid) { | @@ -193,3 +304,24 @@ function getLexicalUnit(luid) { | ||
193 | var lu = lexical_units[i]; | 304 | var lu = lexical_units[i]; |
194 | return lu.base + '-' + lu.sense; | 305 | return lu.base + '-' + lu.sense; |
195 | } | 306 | } |
307 | + | ||
308 | + | ||
309 | +function addPhraseologicalUnit(mwe, glossa, relation, to) { | ||
310 | + 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: ""}; | ||
311 | + var operation = {operation: 'add_unit', unit:lu}; | ||
312 | + lexical_units.push(lu); | ||
313 | + lexical_unit_examples[free_luid] = []; | ||
314 | + frames_operations.push(operation); | ||
315 | + free_luid -= 1; | ||
316 | + return (free_luid + 1); | ||
317 | +} | ||
318 | + | ||
319 | +function addPhraseologicalUnits(frame_id, old_units, mwes, glossa, relation, to) { | ||
320 | + var i; | ||
321 | + var units = []; | ||
322 | + for (i = 0; i < mwes.length; i++) { | ||
323 | + units.push(addPhraseologicalUnit(mwes[i], glossa, relation, to)); | ||
324 | + } | ||
325 | + changeUnits(frame_id, old_units.concat(units)); | ||
326 | +} | ||
327 | + |
semantics/static/js/semantics_roles.js
1 | var roles_display_table = ""; // roles table in html form | 1 | var roles_display_table = ""; // roles table in html form |
2 | +var roles_display_table_full = ""; // with lemma role | ||
2 | var role_name = []; // displayed names of roles | 3 | var role_name = []; // displayed names of roles |
3 | var role_color = []; // colors assigned to roles | 4 | var role_color = []; // colors assigned to roles |
4 | 5 | ||
5 | -function memorizeRoles(roles_display){ | ||
6 | - var i, j, k; | ||
7 | - roles_display_table = '<table border="1" style="font-size: 11px">'; | 6 | +function rolesToHtml(roles_display, full){ |
7 | + var i, j, k, table; | ||
8 | + table = '<table border="1" style="font-size: 11px">'; | ||
8 | for (i = 0; i < roles_display.length; i++) { | 9 | for (i = 0; i < roles_display.length; i++) { |
9 | - roles_display_table += '<tr>'; | 10 | + table += '<tr>'; |
10 | for (j = 0; j < roles_display[i].length; j++) { | 11 | for (j = 0; j < roles_display[i].length; j++) { |
11 | - roles_display_table += '<td rowspan="'; | ||
12 | - roles_display_table += roles_display[i][j].rowspan; | ||
13 | - roles_display_table += '" colspan="'; | ||
14 | - roles_display_table += roles_display[i][j].colspan; | ||
15 | - roles_display_table += '">'; | 12 | + table += '<td rowspan="'; |
13 | + table += roles_display[i][j].rowspan; | ||
14 | + table += '" colspan="'; | ||
15 | + table += roles_display[i][j].colspan; | ||
16 | + table += '">'; | ||
16 | if (roles_display[i][j].caption != "None") { | 17 | if (roles_display[i][j].caption != "None") { |
17 | - roles_display_table += "<b>" | ||
18 | - roles_display_table += roles_display[i][j].caption; | ||
19 | - roles_display_table += "</b>" | 18 | + table += "<b>" |
19 | + table += roles_display[i][j].caption; | ||
20 | + table += "</b>" | ||
20 | } | 21 | } |
21 | for (k = 0; k < roles_display[i][j].roles.length; k++) { | 22 | for (k = 0; k < roles_display[i][j].roles.length; k++) { |
22 | - roles_display_table += '<div style='; | 23 | + table += '<div style='; |
23 | if (roles_display[i][j].roles[k].color != 'None') { | 24 | if (roles_display[i][j].roles[k].color != 'None') { |
24 | - roles_display_table += '"background-color: rgb(' + roles_display[i][j].roles[k].color + ')'; | 25 | + table += '"background-color: rgb(' + roles_display[i][j].roles[k].color + ')'; |
25 | } else { | 26 | } else { |
26 | - roles_display_table += '"background: linear-gradient(to ' + roles_display[i][j].roles[k].gradient + ', rgba(100,100,100,0.1), rgba(100,100,100,1))'; | 27 | + table += '"background: linear-gradient(to ' + roles_display[i][j].roles[k].gradient + ', rgba(100,100,100,0.1), rgba(100,100,100,1))'; |
27 | } | 28 | } |
28 | - roles_display_table += '"><input type="checkbox" name="roles" value="'; | ||
29 | - roles_display_table += roles_display[i][j].roles[k].id; | ||
30 | - roles_display_table += '"><label>'; | ||
31 | - roles_display_table += roles_display[i][j].roles[k].rolename; | ||
32 | - roles_display_table += '</label></div>'; | ||
33 | - role_name[roles_display[i][j].roles[k].id] = roles_display[i][j].roles[k].rolename; | ||
34 | - role_color[roles_display[i][j].roles[k].id] = {"color": roles_display[i][j].roles[k].color, "gradient": roles_display[i][j].roles[k].gradient}; | 29 | + table += '"><input type="checkbox" name="roles" value="'; |
30 | + table += roles_display[i][j].roles[k].id; | ||
31 | + table += '"><label>'; | ||
32 | + table += roles_display[i][j].roles[k].rolename; | ||
33 | + table += '</label></div>'; | ||
34 | + if (full) { | ||
35 | + role_name[roles_display[i][j].roles[k].id] = roles_display[i][j].roles[k].rolename; | ||
36 | + role_color[roles_display[i][j].roles[k].id] = {"color": roles_display[i][j].roles[k].color, "gradient": roles_display[i][j].roles[k].gradient}; | ||
37 | + } | ||
35 | } | 38 | } |
36 | - roles_display_table += '</td>'; | 39 | + table += '</td>'; |
37 | } | 40 | } |
38 | - roles_display_table += '</tr>'; | 41 | + table += '</tr>'; |
39 | } | 42 | } |
40 | - roles_display_table += '</table>'; | 43 | + table += '</table>'; |
44 | + | ||
45 | + return table; | ||
46 | +} | ||
47 | + | ||
48 | +function memorizeRoles(roles_display, roles_full){ | ||
49 | + roles_display_table = rolesToHtml(roles_display, false); | ||
50 | + roles_display_table_full = rolesToHtml(roles_full, true); | ||
41 | } | 51 | } |
42 | 52 | ||
43 | function getStyle(frame_id, complement_num) { | 53 | function getStyle(frame_id, complement_num) { |
44 | style_type = ""; | 54 | style_type = ""; |
45 | style_color = ""; | 55 | style_color = ""; |
46 | style_value = "" | 56 | style_value = "" |
47 | - roles = frame_content[parseInt(frame_id)].display.roles[complement_num].argument; | 57 | + var roles = frame_content[parseInt(frame_id)].display.roles[complement_num].argument; |
48 | var i; | 58 | var i; |
49 | for (i = 0; i < roles.length; i++) { | 59 | for (i = 0; i < roles.length; i++) { |
50 | var color = role_color[roles[i]]; | 60 | var color = role_color[roles[i]]; |
@@ -63,3 +73,15 @@ function getStyle(frame_id, complement_num) { | @@ -63,3 +73,15 @@ function getStyle(frame_id, complement_num) { | ||
63 | } | 73 | } |
64 | return {"type": style_type, "value": style_value}; | 74 | return {"type": style_type, "value": style_value}; |
65 | } | 75 | } |
76 | + | ||
77 | +function isPOL(frame_id, complement_num) { | ||
78 | + var roles = frame_content[parseInt(frame_id)].display.roles[complement_num].argument; | ||
79 | + if (roles.length != 1) { | ||
80 | + return false; | ||
81 | + } | ||
82 | + if (role_name[roles[0]] == 'Lemma') { | ||
83 | + return true; | ||
84 | + } else { | ||
85 | + return false; | ||
86 | + } | ||
87 | +} |
semantics/static/js/semantics_schemas.js
1 | +var subentry_display = []; | ||
1 | var ranks = {}; // lexical unit based rank of schema | 2 | var ranks = {}; // lexical unit based rank of schema |
2 | var schemas_content = []; // schemas in html form | 3 | var schemas_content = []; // schemas in html form |
3 | var default_order = []; // default order of schemas | 4 | var default_order = []; // default order of schemas |
@@ -106,7 +107,7 @@ function schemaHeader(schema, alternates){ | @@ -106,7 +107,7 @@ function schemaHeader(schema, alternates){ | ||
106 | return schema_header; | 107 | return schema_header; |
107 | } | 108 | } |
108 | 109 | ||
109 | -function schemaBody(schema, alternation){ | 110 | +function schemaBody(schema, alternation, lex){ |
110 | var schema_body = ''; | 111 | var schema_body = ''; |
111 | 112 | ||
112 | if (alternation != 1) { | 113 | if (alternation != 1) { |
@@ -117,7 +118,7 @@ function schemaBody(schema, alternation){ | @@ -117,7 +118,7 @@ function schemaBody(schema, alternation){ | ||
117 | schema_body += '<td class="ColumnHeader">Funkcja:</td>'; | 118 | schema_body += '<td class="ColumnHeader">Funkcja:</td>'; |
118 | var display = schema.display; | 119 | var display = schema.display; |
119 | for (k = 0; k < display.categories.length; k++) { | 120 | for (k = 0; k < display.categories.length; k++) { |
120 | - schema_body += '<td class="' + display.categories[k].csv_class + 'alt_' + alternation + '_" id="' + display.categories[k].csv_class + 'alt_' + alternation + '_" onclick="schemaClick(\'' + display.categories[k].csv_id + 'alt_' + alternation + '_\')">'; | 121 | + schema_body += '<td class="' + display.categories[k].csv_class + 'alt_' + alternation + '_" id="' + display.categories[k].csv_class + 'alt_' + alternation + '_" onclick="schemaClick(\'' + display.categories[k].csv_id + 'alt_' + alternation + '_\', [])">'; |
121 | schema_body += display.categories[k].argument; | 122 | schema_body += display.categories[k].argument; |
122 | schema_body += '</td>'; | 123 | schema_body += '</td>'; |
123 | position_arguments[display.categories[k].csv_class + 'alt_' + alternation + '_'] = []; | 124 | position_arguments[display.categories[k].csv_class + 'alt_' + alternation + '_'] = []; |
@@ -127,7 +128,12 @@ function schemaBody(schema, alternation){ | @@ -127,7 +128,12 @@ function schemaBody(schema, alternation){ | ||
127 | schema_body += '<td class="ColumnHeader" rowspan="' + schema.rowspan + '">Typy fraz:</td>'; | 128 | schema_body += '<td class="ColumnHeader" rowspan="' + schema.rowspan + '">Typy fraz:</td>'; |
128 | for (k = 0; k < display.arguments.length; k++) { | 129 | for (k = 0; k < display.arguments.length; k++) { |
129 | for (l = 0; l < display.arguments[k].length; l++) { | 130 | for (l = 0; l < display.arguments[k].length; l++) { |
130 | - schema_body += '<td id="' + display.arguments[k][l].csv_id + 'alt_' + alternation + '_" class="' + display.arguments[k][l].csv_class + 'alt_' + alternation + '_" onclick="schemaClick(\'' + display.arguments[k][l].csv_id + 'alt_' + alternation +'_\')">'; | 131 | + schema_body += '<td id="' + display.arguments[k][l].csv_id + 'alt_' + alternation + '_" class="' + display.arguments[k][l].csv_class + 'alt_' + alternation + '_" onclick="schemaClick(\'' + display.arguments[k][l].csv_id + 'alt_' + alternation +'_\', '; |
132 | + if (display.arguments[k][l].lex.length != 0) { | ||
133 | + schema_body += '[\'' + display.arguments[k][l].lex.join('\', \'') + '\'])">'; | ||
134 | + } else { | ||
135 | + schema_body += '[])">'; | ||
136 | + } | ||
131 | schema_body += display.arguments[k][l].argument; | 137 | schema_body += display.arguments[k][l].argument; |
132 | schema_body += '</td>'; | 138 | schema_body += '</td>'; |
133 | if (parseInt(display.arguments[k][l].csv_id.split('_')[5]) >= 0) { | 139 | if (parseInt(display.arguments[k][l].csv_id.split('_')[5]) >= 0) { |
@@ -147,6 +153,7 @@ function alternationCounts(alternations) { | @@ -147,6 +153,7 @@ function alternationCounts(alternations) { | ||
147 | 153 | ||
148 | function displaySchemas(lemma, characteristic_display){ | 154 | function displaySchemas(lemma, characteristic_display){ |
149 | var i, j, k, l; | 155 | var i, j, k, l; |
156 | + subentry_display = characteristic_display; | ||
150 | var schemas_display = ""; | 157 | var schemas_display = ""; |
151 | for (i = 0; i < characteristic_display.length; i++) { | 158 | for (i = 0; i < characteristic_display.length; i++) { |
152 | char_id = characteristic_display[i].characteristic_id; | 159 | char_id = characteristic_display[i].characteristic_id; |
@@ -205,3 +212,23 @@ function redrawSchemas(frame) { | @@ -205,3 +212,23 @@ function redrawSchemas(frame) { | ||
205 | } | 212 | } |
206 | } | 213 | } |
207 | } | 214 | } |
215 | + | ||
216 | + | ||
217 | +function hasRefl(schema) { | ||
218 | + // TODO: refl i recip w schemacie | ||
219 | + var sid = schemaId(schema); | ||
220 | + var i, j; | ||
221 | + for (i = 0; i < subentry_display.length; i++) { | ||
222 | + var char_display = subentry_display[i].characteristic_display; | ||
223 | + for (j = 0; j < subentry_display[i].schemas.length; j++) { | ||
224 | + if (subentry_display[i].schemas[j].schema_id == sid) { | ||
225 | + if (char_display.search('siฤ') >= 0) { | ||
226 | + return true; | ||
227 | + } else { | ||
228 | + return false; | ||
229 | + } | ||
230 | + } | ||
231 | + } | ||
232 | + } | ||
233 | + return false; | ||
234 | +} |
semantics/static/js/semantics_view.js
@@ -356,6 +356,9 @@ function createFrame() { | @@ -356,6 +356,9 @@ function createFrame() { | ||
356 | } else { | 356 | } else { |
357 | units = f.meaning; | 357 | units = f.meaning; |
358 | } | 358 | } |
359 | + if ((typeof units) == 'undefined') { | ||
360 | + units = []; | ||
361 | + } | ||
359 | 362 | ||
360 | frameClick(""); | 363 | frameClick(""); |
361 | newFrame(units); | 364 | newFrame(units); |
@@ -376,6 +379,47 @@ function createFrame() { | @@ -376,6 +379,47 @@ function createFrame() { | ||
376 | 379 | ||
377 | function changeLexicalUnits() { | 380 | function changeLexicalUnits() { |
378 | 381 | ||
382 | + var getRelation = | ||
383 | + function(f) { | ||
384 | + return '<label>Relacja <select name="relation" disabled><option value="' + f.relation + '">' + relations_creating[parseInt(f.relation)] + '</option></label></select><br />'; | ||
385 | + }; | ||
386 | + | ||
387 | + var getRelationsForm = | ||
388 | + function () { | ||
389 | + var result = '<label>Relacja '; | ||
390 | + result += '<select id="synset_input_relation" name="relation" onchange="changeSynsetInput()">'; | ||
391 | + result += '<option value="0">' + relations_creating[0] + '</option>'; | ||
392 | + result += '<option value="1">' + relations_creating[1] + '</option>'; | ||
393 | + result += '<option value="2">' + relations_creating[2] + '</option>'; | ||
394 | + result += '</select></label><br />'; | ||
395 | + return result; | ||
396 | + }; | ||
397 | + | ||
398 | + var units = []; | ||
399 | + var mwes = []; | ||
400 | + var a = ""; | ||
401 | + var gloss = ""; | ||
402 | + | ||
403 | + var addPhraseology = | ||
404 | + function(e,v,m,f){ | ||
405 | + e.preventDefault(); | ||
406 | + if (v == -1) | ||
407 | + $.prompt.goToState('state0'); | ||
408 | + if (v == 0) { | ||
409 | + $.prompt.close(); | ||
410 | + } | ||
411 | + if (v == 1) { | ||
412 | + changeUnits(highlighted_id, units); | ||
413 | + | ||
414 | + addPhraseologicalUnits(highlighted_id, units, mwes, f.glossa, f.relation, f.synset); | ||
415 | + | ||
416 | + frameClick(""); | ||
417 | + displayFrames(); | ||
418 | + frameClick(a); | ||
419 | + $.prompt.close(); | ||
420 | + } | ||
421 | + }; | ||
422 | + | ||
379 | var change_units = { | 423 | var change_units = { |
380 | state0: { | 424 | state0: { |
381 | title: 'Zmiana jednostek leksykalnych', | 425 | title: 'Zmiana jednostek leksykalnych', |
@@ -383,30 +427,69 @@ function changeLexicalUnits() { | @@ -383,30 +427,69 @@ function changeLexicalUnits() { | ||
383 | buttons: { "Anuluj": -1, "Potwierdลบ": 1 }, | 427 | buttons: { "Anuluj": -1, "Potwierdลบ": 1 }, |
384 | focus: 1, | 428 | focus: 1, |
385 | submit:function(e,v,m,f){ | 429 | submit:function(e,v,m,f){ |
386 | - e.preventDefault(); | ||
387 | - if (v == -1) { | ||
388 | - $.prompt.close(); | ||
389 | - } | ||
390 | - if (v == 1) { | ||
391 | - | ||
392 | - var units = normalizeFormData(f.meaning); | ||
393 | - if (units.length > 0) { | ||
394 | - | ||
395 | - var a = semantics_selected_id; | ||
396 | - changeUnits(highlighted_id, units); | ||
397 | - frameClick(""); | ||
398 | - displayFrames(); | ||
399 | - frameClick(a); | ||
400 | - | 430 | + e.preventDefault(); |
431 | + if (v == -1) { | ||
432 | + $.prompt.close(); | ||
433 | + } | ||
434 | + if (v == 1) { | ||
435 | + | ||
436 | + units = normalizeFormData(f.meaning); | ||
437 | + mwes = normalizeFormData(f.mwe); | ||
438 | + a = semantics_selected_id; | ||
439 | + | ||
440 | + if (mwes.length == 0) { | ||
441 | + changeUnits(highlighted_id, units); | ||
442 | + | ||
443 | + frameClick(""); | ||
444 | + displayFrames(); | ||
445 | + frameClick(a); | ||
446 | + $.prompt.close(); | ||
447 | + } else { | ||
448 | + $.prompt.goToState('state1'); | ||
449 | + attachPlWNContextAutocomplete(); | ||
450 | + } | ||
451 | + | ||
452 | + } | ||
453 | + } | ||
454 | + }, | ||
455 | + state1: { /* nowa frazeologia */ | ||
456 | + title: 'Nowe jednostki frazeologiczne', | ||
457 | + html: '<label>Glossa <input type="text" name="glossa" value=""></label><br />' + | ||
458 | + getRelationsForm() + "<label id=\"synset_input\">w stosunku do <input id=\"plWN_context_selection\" type=\"text\" name=\"context\"></label>", | ||
459 | + buttons: { "Wstecz": -1, "Anuluj": 0, "Potwierdลบ": 1 }, | ||
460 | + focus: 1, | ||
461 | + submit:function(e,v,m,f){ | ||
462 | + e.preventDefault(); | ||
463 | + if (v == -1) { | ||
464 | + $.prompt.goToState('state0'); | ||
465 | + } | ||
466 | + if (v == 0) { | ||
401 | $.prompt.close(); | 467 | $.prompt.close(); |
402 | - | ||
403 | - } else { | ||
404 | - | ||
405 | - alert("Naleลผy wybraฤ co najmniej jednฤ jednostkฤ leksykalnฤ dla ramy"); | ||
406 | - | ||
407 | } | 468 | } |
408 | - } | ||
409 | - } | 469 | + if (v == 1) { |
470 | + if (parseInt(f.relation) != 2) { | ||
471 | + /* podana lokalizacja w Sลowosieci */ | ||
472 | + $.prompt.removeState('state2'); | ||
473 | + $.prompt.addState('state2', | ||
474 | + { | ||
475 | + title: 'Znaczenia', | ||
476 | + html: '<label>Glossa <input type="text" name="glossa" value="' + gloss + '" disabled></label><br />' + | ||
477 | + getRelation(f) + "w stosunku do:<br />" + getSynsets(f.context, "czasownik"), | ||
478 | + buttons: {Wstecz: -1, Anuluj: 0, Zatwierdลบ: 1}, | ||
479 | + focus: 1, | ||
480 | + submit: addPhraseology | ||
481 | + }) | ||
482 | + $.prompt.goToState('state2'); | ||
483 | + } else { | ||
484 | + /* zignorowane umiejscowienie w Sลowosieci */ | ||
485 | + addPhraseologicalUnits(highlighted_id, units, mwes, f.glossa, f.relation, -1); | ||
486 | + frameClick(""); | ||
487 | + displayFrames(); | ||
488 | + frameClick(a) | ||
489 | + $.prompt.close(); | ||
490 | + } | ||
491 | + } | ||
492 | + } | ||
410 | }, | 493 | }, |
411 | }; | 494 | }; |
412 | if (change == true) { | 495 | if (change == true) { |
@@ -1018,8 +1101,13 @@ function color(what, how, disconnected_background, disconnected_text) { | @@ -1018,8 +1101,13 @@ function color(what, how, disconnected_background, disconnected_text) { | ||
1018 | 1101 | ||
1019 | } | 1102 | } |
1020 | 1103 | ||
1021 | -function schemaClick(class_id) { | 1104 | +function schemaClick(class_id, lex) { |
1022 | 1105 | ||
1106 | + var table = roles_display_table; | ||
1107 | + if (lex.length != 0){ | ||
1108 | + table = roles_display_table_full; | ||
1109 | + } | ||
1110 | + | ||
1023 | var field_ids; | 1111 | var field_ids; |
1024 | if (class_id.split('arg').length == 1) { | 1112 | if (class_id.split('arg').length == 1) { |
1025 | field_ids = position_arguments[class_id].slice(); | 1113 | field_ids = position_arguments[class_id].slice(); |
@@ -1045,7 +1133,7 @@ function schemaClick(class_id) { | @@ -1045,7 +1133,7 @@ function schemaClick(class_id) { | ||
1045 | var choose_role = { | 1133 | var choose_role = { |
1046 | state0: { | 1134 | state0: { |
1047 | title: 'Wybierz rolฤ', | 1135 | title: 'Wybierz rolฤ', |
1048 | - html: roles_display_table, | 1136 | + html: table, |
1049 | buttons: { Anuluj: -1, Zatwierdลบ: 1 }, | 1137 | buttons: { Anuluj: -1, Zatwierdลบ: 1 }, |
1050 | focus: 1, | 1138 | focus: 1, |
1051 | close: function(){return result;}, | 1139 | close: function(){return result;}, |
semantics/templates/roles.json
1 | -{"roles_display": [ | 1 | +{% load jsonify %} |
2 | 2 | ||
3 | - | ||
4 | - {% for row, outer_comma in roles_display %} | ||
5 | - [ | ||
6 | - {% for caption, rowspan, colspan, roles, row_comma in row %} | ||
7 | - { | ||
8 | - "caption": "{{ caption }}", "rowspan": {{ rowspan }}, "colspan": {{ colspan }}, "roles": [ | ||
9 | - {% for role, inner_comma in roles %} | ||
10 | - { "id": {{ role.id }}, "rolename": "{{ role.role }}", "color": "{{ role.color }}", "gradient": "{{ role.gradient }}" }{{ inner_comma }} | ||
11 | - {% endfor %} | ||
12 | - ] | ||
13 | - } {{ row_comma }} | ||
14 | - {% endfor %} | ||
15 | - ] {{ outer_comma }} | ||
16 | - {% endfor %} | ||
17 | - | ||
18 | - | ||
19 | -]} | 3 | +{ |
4 | + "roles_display": {{ roles_display|jsonify }}, | ||
5 | + "roles_full": {{ roles_full|jsonify }} | ||
6 | +} |
semantics/templates/semantics.html
@@ -35,7 +35,7 @@ | @@ -35,7 +35,7 @@ | ||
35 | }); | 35 | }); |
36 | 36 | ||
37 | $.getJSON(ajax_roles, function(data){ | 37 | $.getJSON(ajax_roles, function(data){ |
38 | - memorizeRoles(data.roles_display); | 38 | + memorizeRoles(data.roles_display, data.roles_full); |
39 | $.getJSON(ajax_opinions, {lemma_id: {{ lemma.id }}}, function(data){ | 39 | $.getJSON(ajax_opinions, {lemma_id: {{ lemma.id }}}, function(data){ |
40 | memorizeOpinions(data.opinions); | 40 | memorizeOpinions(data.opinions); |
41 | $.getJSON(ajax_frames, {lemma_id: {{ lemma.id }}}, function(data){ | 41 | $.getJSON(ajax_frames, {lemma_id: {{ lemma.id }}}, function(data){ |
semantics/views.py
@@ -8,7 +8,7 @@ from semantics.models import SemanticRole, SemanticFrame, Complement, \ | @@ -8,7 +8,7 @@ from semantics.models import SemanticRole, SemanticFrame, Complement, \ | ||
8 | from wordnet.models import Hypernymy, Synonymy | 8 | from wordnet.models import Hypernymy, Synonymy |
9 | 9 | ||
10 | from dictionary.models import Frame_Char_Model, Lemma, Lemma_Status, \ | 10 | from dictionary.models import Frame_Char_Model, Lemma, Lemma_Status, \ |
11 | - sort_arguments, sort_positions | 11 | + sort_arguments, sort_positions, sortatributes |
12 | from dictionary.ajax_lemma_view import user_can_modify | 12 | from dictionary.ajax_lemma_view import user_can_modify |
13 | from django.core.exceptions import SuspiciousOperation | 13 | from django.core.exceptions import SuspiciousOperation |
14 | from django.core.urlresolvers import reverse | 14 | from django.core.urlresolvers import reverse |
@@ -18,6 +18,7 @@ from common.decorators import render, ajax | @@ -18,6 +18,7 @@ from common.decorators import render, ajax | ||
18 | from semantics.saving import modify_frames, update_meanings | 18 | from semantics.saving import modify_frames, update_meanings |
19 | from semantics.validation import validate_schemas, validate_frames, validate_lexical_units | 19 | from semantics.validation import validate_schemas, validate_frames, validate_lexical_units |
20 | 20 | ||
21 | +from settings import MORFEUSZ2 | ||
21 | 22 | ||
22 | ####################################### render ##################################### | 23 | ####################################### render ##################################### |
23 | 24 | ||
@@ -74,8 +75,8 @@ def reorder_history(frames_list): | @@ -74,8 +75,8 @@ def reorder_history(frames_list): | ||
74 | def ajax_frames(request, lemma_id): | 75 | def ajax_frames(request, lemma_id): |
75 | 76 | ||
76 | lemma = Lemma.objects.get(id=lemma_id, old=False) | 77 | lemma = Lemma.objects.get(id=lemma_id, old=False) |
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') | 78 | + # lexical_units = LexicalUnit.objects.filter(Q(base=lemma.entry, pos="czasownik")|Q(base=lemma.entry+u' siฤ', pos="czasownik")).order_by('sense') |
79 | + 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') | ||
79 | 80 | ||
80 | alternations = {} | 81 | alternations = {} |
81 | frames_dict = {} | 82 | frames_dict = {} |
@@ -96,8 +97,6 @@ def ajax_frames(request, lemma_id): | @@ -96,8 +97,6 @@ def ajax_frames(request, lemma_id): | ||
96 | type_frames[t] = [] | 97 | type_frames[t] = [] |
97 | type_frames[tuple(frame_units[frame_id])].append(frames_dict[frame_id]) | 98 | type_frames[tuple(frame_units[frame_id])].append(frames_dict[frame_id]) |
98 | 99 | ||
99 | -# ala[ma]=kot | ||
100 | - | ||
101 | frames_display = [] | 100 | frames_display = [] |
102 | complement_arguments = {} | 101 | complement_arguments = {} |
103 | arguments_frame_connected = {} | 102 | arguments_frame_connected = {} |
@@ -194,7 +193,7 @@ def ajax_frames(request, lemma_id): | @@ -194,7 +193,7 @@ def ajax_frames(request, lemma_id): | ||
194 | frames_display.append(frame_display) | 193 | frames_display.append(frame_display) |
195 | 194 | ||
196 | # ala["ma"] = "kot" | 195 | # ala["ma"] = "kot" |
197 | - | 196 | + |
198 | context = { | 197 | context = { |
199 | 'frames_display': frames_display, | 198 | 'frames_display': frames_display, |
200 | 'connections': {'connected': complement_arguments, 'connected_reverse': arguments_frame_connected}, | 199 | 'connections': {'connected': complement_arguments, 'connected_reverse': arguments_frame_connected}, |
@@ -208,8 +207,8 @@ def ajax_frames(request, lemma_id): | @@ -208,8 +207,8 @@ def ajax_frames(request, lemma_id): | ||
208 | @ajax(method='get', encode_result=False) | 207 | @ajax(method='get', encode_result=False) |
209 | def ajax_units(request, lemma_id): | 208 | def ajax_units(request, lemma_id): |
210 | lemma = Lemma.objects.get(id=lemma_id, old=False) | 209 | lemma = Lemma.objects.get(id=lemma_id, old=False) |
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 | + # lexical_units = LexicalUnit.objects.filter(Q(base = lemma.entry, pos="czasownik")|Q(base = lemma.entry + u' siฤ', pos="czasownik")).order_by('base', 'sense') |
211 | + 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') | ||
213 | 212 | ||
214 | context = { | 213 | context = { |
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], | 214 | '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], |
@@ -293,25 +292,46 @@ def ajax_opinions(request): | @@ -293,25 +292,46 @@ def ajax_opinions(request): | ||
293 | 292 | ||
294 | return context | 293 | return context |
295 | 294 | ||
295 | +def NoneisNone(o): | ||
296 | + if o is None: | ||
297 | + return 'None' | ||
298 | + else: | ||
299 | + return o | ||
300 | + | ||
296 | @render('roles.json') | 301 | @render('roles.json') |
297 | @ajax(method='get', encode_result=False) | 302 | @ajax(method='get', encode_result=False) |
298 | def ajax_roles(request): | 303 | def ajax_roles(request): |
299 | roles_display = [] | 304 | roles_display = [] |
300 | maxrow = SemanticRolesDisplay.objects.all().order_by('-row')[0].row | 305 | maxrow = SemanticRolesDisplay.objects.all().order_by('-row')[0].row |
301 | - for i in range(1, maxrow + 1): | 306 | + for i in range(1, maxrow): |
302 | row = [] | 307 | row = [] |
303 | cells = SemanticRolesDisplay.objects.filter(row=i).order_by('column') | 308 | cells = SemanticRolesDisplay.objects.filter(row=i).order_by('column') |
304 | for cell in cells: | 309 | for cell in cells: |
305 | - content = cell.roles.all().order_by('id') | ||
306 | - commas = [','] * max(len(content) - 1, 0) + [''] | ||
307 | - row.append((cell.caption, cell.rowspan, cell.colspan, zip(content, commas))) | ||
308 | - commas = [','] * max(len(row) - 1, 0) + [''] | ||
309 | - captions, rowspans, colspans, contents = zip(*row) | ||
310 | - roles_display.append(zip(list(captions), list(rowspans), list(colspans), list(contents), commas)) | ||
311 | - commas = [','] * max(len(roles_display) - 1, 0) + [''] | 310 | + roles = [{"id": r.id, "rolename": r.role, "color": NoneisNone(r.color), "gradient": NoneisNone(r.gradient)} for r in cell.roles.all().order_by('id')] |
311 | + row.append({"caption": NoneisNone(cell.caption), | ||
312 | + "rowspan": cell.rowspan, | ||
313 | + "colspan": cell.colspan, | ||
314 | + "roles": roles}) | ||
315 | + roles_display.append(row) | ||
316 | + | ||
317 | + roles_short = roles_display[:] | ||
318 | + | ||
319 | + row = [] | ||
320 | + cells = SemanticRolesDisplay.objects.filter(row=maxrow).order_by('column') | ||
321 | + for cell in cells: | ||
322 | + roles = [{"id": r.id, "rolename": r.role, "color": NoneisNone(r.color), "gradient": NoneisNone(r.gradient)} for r in cell.roles.all().order_by('id')] | ||
323 | + row.append({"caption": NoneisNone(cell.caption), | ||
324 | + "rowspan": cell.rowspan, | ||
325 | + "colspan": cell.colspan, | ||
326 | + "roles": roles}) | ||
327 | + roles_display.append(row) | ||
328 | + | ||
329 | + roles_full = roles_display | ||
330 | + | ||
312 | 331 | ||
313 | context = { | 332 | context = { |
314 | - 'roles_display': zip(roles_display, commas), | 333 | + 'roles_display': roles_short, |
334 | + 'roles_full': roles_full | ||
315 | } | 335 | } |
316 | 336 | ||
317 | return context | 337 | return context |
@@ -373,13 +393,22 @@ def ajax_schemas(request, lemma_id): | @@ -373,13 +393,22 @@ def ajax_schemas(request, lemma_id): | ||
373 | for schema_id, position in zip(schema_ids, ordered_positions): | 393 | for schema_id, position in zip(schema_ids, ordered_positions): |
374 | if position.arguments.count() > i: | 394 | if position.arguments.count() > i: |
375 | ordered_arguments = sort_arguments(position.arguments.all()) | 395 | ordered_arguments = sort_arguments(position.arguments.all()) |
376 | - row.append(unicode(ordered_arguments[i])) | 396 | + row.append((unicode(ordered_arguments[i]), ordered_arguments[i])) |
377 | idents.append(schema_id + 'arg_' + str(ordered_arguments[i].id) + '_') | 397 | idents.append(schema_id + 'arg_' + str(ordered_arguments[i].id) + '_') |
378 | else: # this category has fewer posible argument realizations | 398 | else: # this category has fewer posible argument realizations |
379 | - row.append('') | 399 | + row.append(('', None)) |
380 | idents.append(schema_id + 'arg_-' + str(i + 1) + '_') | 400 | idents.append(schema_id + 'arg_-' + str(i + 1) + '_') |
381 | # identifier, class, argument | 401 | # identifier, class, argument |
382 | - display["arguments"].append([{"csv_id": i, "csv_class": c, "argument": a} for i, c, a in zip(idents, schema_ids, row)]) | 402 | + arg = [] |
403 | + #ma["ala"] = kot | ||
404 | + for i, c, a in zip(idents, schema_ids, row): | ||
405 | + astr, aobj = a | ||
406 | + if aobj is not None and aobj.is_phraseologic(): | ||
407 | + lex = lexicalisation(aobj) | ||
408 | + else: | ||
409 | + lex = [] | ||
410 | + arg.append({"csv_id": i, "csv_class": c, "argument": astr, "lex": lex}) | ||
411 | + display["arguments"].append(arg) | ||
383 | 412 | ||
384 | schema_display["schemas"].append({"schema_id": str(schema.id), "grade": lemma.get_schema_opinion(schema), "colspan": str(max(len(schema_categories), 1)), "rowspan": str(schema_arguments_rowspan), "display": display, "phraseologic": schema.phraseologic}) | 413 | schema_display["schemas"].append({"schema_id": str(schema.id), "grade": lemma.get_schema_opinion(schema), "colspan": str(max(len(schema_categories), 1)), "rowspan": str(schema_arguments_rowspan), "display": display, "phraseologic": schema.phraseologic}) |
385 | 414 | ||
@@ -400,6 +429,62 @@ def ajax_schemas(request, lemma_id): | @@ -400,6 +429,62 @@ def ajax_schemas(request, lemma_id): | ||
400 | 429 | ||
401 | return context | 430 | return context |
402 | 431 | ||
432 | +def lexicalisation(argument): | ||
433 | + b = argument.type | ||
434 | + attributes = sortatributes(argument) | ||
435 | + lexicalisation_type = attributes[0].values.all()[0].argument.type | ||
436 | + lexicalisation_parameters = sortatributes(attributes[0].values.all()[0].argument) | ||
437 | + if lexicalisation_type == 'np': # np(case), number, nouns, atr | ||
438 | + nps = get_nps(get_case(lexicalisation_parameters[0]), get_number(attributes[1]), get_words(attributes[2]), attributes[3]) | ||
439 | + return nps | ||
440 | + elif lexicalisation_type == 'prepnp': #prepnp(prep, case), number, nouns, atr | ||
441 | + prepnps = get_prepnps(get_preposition(lexicalisation_parameters[0]), get_case(lexicalisation_parameters[1]), get_number(attributes[1]), get_words(attributes[2]), attributes[3]) | ||
442 | + return prepnps | ||
443 | + else: | ||
444 | + return [] | ||
445 | + return [] | ||
446 | + | ||
447 | +def get_preposition(attribute): | ||
448 | + return attribute.values.all()[0].parameter.type.name | ||
449 | + | ||
450 | +def get_words(attribute): | ||
451 | + words = [word.text[1:-1] for word in attribute.values.all()] | ||
452 | + return words | ||
453 | + | ||
454 | +def get_case(attribute): | ||
455 | + case = attribute.values.all()[0].parameter.type.name | ||
456 | + if case == u'str': | ||
457 | + case = u'acc' | ||
458 | + return case | ||
459 | + | ||
460 | +def get_number(attribute): | ||
461 | + number = attribute.values.all()[0].parameter.type.name | ||
462 | + return number | ||
463 | + | ||
464 | +def get_nps(case, number, nouns, _atr): | ||
465 | + result = [] | ||
466 | + for noun in nouns: | ||
467 | + options = [(interp.orth, interp.getTag(MORFEUSZ2)) for interp in MORFEUSZ2.generate(noun.encode('utf8'))] | ||
468 | + if case != u'_': | ||
469 | + filtered = [] | ||
470 | + for option in options: | ||
471 | + (orth, tag) = option | ||
472 | + if case in tag: | ||
473 | + filtered.append(option) | ||
474 | + options = filtered | ||
475 | + if number != u'_': | ||
476 | + filtered = [] | ||
477 | + for option in options: | ||
478 | + (orth, tag) = option | ||
479 | + if number in tag: | ||
480 | + filtered.append(option) | ||
481 | + options = filtered | ||
482 | + return [orth for orth, _ in options] | ||
483 | + | ||
484 | +def get_prepnps(prep, case, number, nouns, _atr): | ||
485 | + nps = get_nps(case, number, nouns, _atr) | ||
486 | + return [prep + ' ' + np for np in nps] | ||
487 | + | ||
403 | @render('examples.json') | 488 | @render('examples.json') |
404 | @ajax(method='get', encode_result=False) | 489 | @ajax(method='get', encode_result=False) |
405 | def ajax_examples(request, lemma_id): | 490 | def ajax_examples(request, lemma_id): |