Commit 04becbf6a571aa0ff8c2bc8fbe7af669e6d72e76
Merge branch 'tomek' into dev
Showing
1 changed file
with
24 additions
and
10 deletions
semantics/static/js/semantics_lexical_units.js
... | ... | @@ -276,15 +276,16 @@ function getMeaningsSelectionForFrame(frame_id) { |
276 | 276 | } |
277 | 277 | |
278 | 278 | function getFormForLexicalisation(lexicalisation) { |
279 | - var result = ""; | |
279 | + var options = []; | |
280 | 280 | var i; |
281 | 281 | for (i = 0; i < lexicalisation.length; i++) { |
282 | 282 | var perms = permute(lexicalisation[i].args); |
283 | 283 | var j; |
284 | 284 | for (j = 0; j < perms.length; j++) { |
285 | - result += lexicalisationForm(lexicalisation[i].lemma, lexicalisation[i].pre, cartesian(perms[j])); | |
285 | + options.push({lemma: lexicalisation[i].lemma, pre: lexicalisation[i].pre, post: cartesian(perms[j])}); | |
286 | 286 | } |
287 | 287 | } |
288 | + result = lexicalisationForm(options); | |
288 | 289 | return result; |
289 | 290 | } |
290 | 291 | |
... | ... | @@ -332,19 +333,28 @@ function cartesian(llist) { |
332 | 333 | return result; |
333 | 334 | } |
334 | 335 | |
335 | -function lexicalisationForm(lemma, pre, tokenised) { | |
336 | - var list; | |
337 | - if (pre.length == 0) { | |
338 | - list = noSubjUnits(lemma, tokenised); | |
339 | - } else { | |
340 | - list = subjUnits(pre, lemma, tokenised); | |
336 | +function lexicalisationForm(lemmalist) { | |
337 | + var i; | |
338 | + var options = []; | |
339 | + for (k = 0; k < lemmalist.length; k++) { | |
340 | + var lemma = lemmalist[k].lemma; | |
341 | + var pre = lemmalist[k].pre; | |
342 | + var tokenised = lemmalist[k].post; | |
343 | + var list; | |
344 | + if (pre.length == 0) { | |
345 | + list = noSubjUnits(lemma, tokenised); | |
346 | + } else { | |
347 | + list = subjUnits(pre, lemma, tokenised); | |
348 | + } | |
349 | + options = options.concat(list); | |
341 | 350 | } |
342 | 351 | |
352 | + | |
343 | 353 | $.ajax({ |
344 | 354 | type: "POST", |
345 | 355 | dataType: "json", |
346 | 356 | url: ajax_get_mwes, |
347 | - data: {"options": JSON.stringify(list)}, | |
357 | + data: {"options": JSON.stringify(options)}, | |
348 | 358 | success: function(data){ |
349 | 359 | list = data.mwes; |
350 | 360 | }, |
... | ... | @@ -375,7 +385,11 @@ function noSubjUnits(lemmata, dependants) { |
375 | 385 | result.push(lemmata[i]); |
376 | 386 | } else { |
377 | 387 | for (j = 0; j < dependants.length; j++) { |
378 | - result.push(lemmata[i] + " " + dependants[j].join(" ")); | |
388 | + if (dependants[j].length > 0) { | |
389 | + result.push(lemmata[i] + " " + dependants[j].join(" ")); | |
390 | + } else { | |
391 | + result.push(lemmata[i]); | |
392 | + } | |
379 | 393 | } |
380 | 394 | } |
381 | 395 | } |
... | ... |