summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2015-12-10 14:27:15 +0000
committerhallgren <hallgren@chalmers.se>2015-12-10 14:27:15 +0000
commit6b74a90bd476e44f03bdc0b5c9b896bdf136c23d (patch)
tree9803baef07f3c76df40c92835fea66a036e3eb32 /src
parentbc644e643b05b9c2da402367ef7be20f4cafb247 (diff)
Wide Coveage Translation Demo: sort parse results by probability
Because of the "heurisitc factor", the results returned by the parser might not be in strict probability order. To compensate, a sorting pass has been added to find and show the translation with the highest probability among the 10 first translations. However, this means that the translation demo now immediately has to ask for 10 translations of every segment. Before, it initially asked for only one translation of every segment, and then 9 more translations for a segment when/if the user clicked on it. This change can slow down translation noticeably (e.g. from 15s 30s to load an example with fiction in English).
Diffstat (limited to 'src')
-rw-r--r--src/www/js/wc.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/www/js/wc.js b/src/www/js/wc.js
index 2cd19e289..c32d0f2e8 100644
--- a/src/www/js/wc.js
+++ b/src/www/js/wc.js
@@ -178,7 +178,8 @@ wc.translate=function() {
//if(f.speak.checked) wc.speak(t.text,f.to.value)
if(!so.got_more) {
so.got_more=true
- trans(so.input,1,9)
+ if(so.rs.length<10)
+ trans(so.input,so.rs.length,10-so.rs.length)
}
}
so.target.onclick=show_more
@@ -233,6 +234,8 @@ wc.translate=function() {
}
}
else {
+ function cmp(a,b) { return a.prob-b.prob; }
+ tra=tra.sort(cmp)
for(var ti=0;ti<tra.length;ti++) {
var r=tra[ti]
if(r.linearizations) showit(r,gftranslate.grammar)
@@ -245,7 +248,7 @@ wc.translate=function() {
}
gftranslate.translate(text,f.from.value,wc.languages || f.to.value,i,count,step3)
}
- function step2(text) { trans(text,0,1) }
+ function step2(text) { trans(text,0,10) }
function step2cnl(text) {
function step3cnl(results) {
var trans=results[0].translations