mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
Wide Coverage Demo Web App: bug fix: restore lost quality indications after switching target languages
This commit is contained in:
@@ -97,6 +97,7 @@ function trans_quality(r,to) {
|
|||||||
else {
|
else {
|
||||||
var text=r.linearizations[ix].text
|
var text=r.linearizations[ix].text
|
||||||
if(r.prob==0) return {quality:"high_quality",text:text}
|
if(r.prob==0) return {quality:"high_quality",text:text}
|
||||||
|
else if(r.prob<0) return {quality:"bad_quality",text:text}
|
||||||
else {
|
else {
|
||||||
var t=trans_text_quality(text)
|
var t=trans_text_quality(text)
|
||||||
if(t.quality=="default_quality" && r.tree && r.tree[0]=="?")
|
if(t.quality=="default_quality" && r.tree && r.tree[0]=="?")
|
||||||
|
|||||||
@@ -101,7 +101,8 @@ wc.translate=function() {
|
|||||||
function show_more() {
|
function show_more() {
|
||||||
wc.selected=so
|
wc.selected=so
|
||||||
var r=so.rs[so.current_pick]
|
var r=so.rs[so.current_pick]
|
||||||
if(e) e.innerHTML=(r.prob||"")+"<br>"+(r.tree||"")
|
var prob=r.prob<=0 ? "" : r.prob || ""
|
||||||
|
if(e) e.innerHTML=prob+"<br>"+(r.tree||"")
|
||||||
if(wc.p /*&& so.rs.length>1*/) show_picks()
|
if(wc.p /*&& so.rs.length>1*/) show_picks()
|
||||||
//if(f.speak.checked) wc.speak(t.text,f.to.value)
|
//if(f.speak.checked) wc.speak(t.text,f.to.value)
|
||||||
}
|
}
|
||||||
@@ -121,40 +122,24 @@ wc.translate=function() {
|
|||||||
if(wc.selected==so) show_more()
|
if(wc.selected==so) show_more()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function showit2(r,grammar) {
|
function showit(r,grammar) {
|
||||||
r.grammar=grammar
|
r.grammar=grammar
|
||||||
|
r.t=trans_quality(r,grammar+f.to.value)
|
||||||
so.rs.push(r)
|
so.rs.push(r)
|
||||||
var j=so.rs.length-1
|
var j=so.rs.length-1
|
||||||
if(so.current_pick<0 || so.current_pick==j) show_trans(j)
|
if(so.current_pick<0 || so.current_pick==j) show_trans(j)
|
||||||
else if(wc.selected==so) show_picks()
|
else if(wc.selected==so) show_picks()
|
||||||
//disable(false)
|
//disable(false)
|
||||||
}
|
}
|
||||||
function showit(r,grammar) {
|
|
||||||
r.t=trans_quality(r,grammar+f.to.value)
|
|
||||||
showit2(r,grammar)
|
|
||||||
}
|
|
||||||
function show_words(r) {
|
|
||||||
var g=gftranslate.grammar
|
|
||||||
var ix=find_to(g+f.to.value,r.linearizations)
|
|
||||||
if(ix>=0) {
|
|
||||||
r.t={quality:"bad_quality",text:r.linearizations[ix].text}
|
|
||||||
showit2(r,g)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function word_for_word(text,cont) {
|
function word_for_word(text,cont) {
|
||||||
function step3(tra) {
|
function step3(tra) {
|
||||||
if(tra.length>=1) {
|
if(tra.length>=1) {
|
||||||
var r=tra[0]
|
var r=tra[0]
|
||||||
if(r.error!=undefined) {
|
r.prob = -1
|
||||||
if(i==0 && so.rs.length==0) show_error(tra[0].error)
|
if(r.linearizations) showit(r,gftranslate.grammar)
|
||||||
}
|
|
||||||
else {
|
|
||||||
var r=tra[0]
|
|
||||||
if(r.linearizations) show_words(r)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(i==0 && so.rs.length==0)
|
else if(so.rs.length==0)
|
||||||
show_error("Unable to translate")
|
show_error("Unable to translate")
|
||||||
}
|
}
|
||||||
gftranslate.wordforword(text,f.from.value,wc.languages || f.to.value,step3)
|
gftranslate.wordforword(text,f.from.value,wc.languages || f.to.value,step3)
|
||||||
@@ -214,6 +199,7 @@ wc.translate=function() {
|
|||||||
var i=so.current_pick
|
var i=so.current_pick
|
||||||
if(!rs[i].t) {
|
if(!rs[i].t) {
|
||||||
i=find_pick(rs)
|
i=find_pick(rs)
|
||||||
|
//console.log("Change pick",so.current_pick,i)
|
||||||
so.current_pick=i
|
so.current_pick=i
|
||||||
clear(p)
|
clear(p)
|
||||||
wc.selected=null
|
wc.selected=null
|
||||||
|
|||||||
Reference in New Issue
Block a user