Wide coverage translation web demo improvements

+ Add lexing/unlexing
+ Add a button to swap input and output
+ Minor layout adjustments
This commit is contained in:
hallgren
2014-01-28 16:51:21 +00:00
parent 06bb2a1dad
commit 0386334f49
4 changed files with 50 additions and 25 deletions

View File

@@ -272,3 +272,7 @@ function check_exp(s,cont) {
}
gfshell("cc "+s,check);
}
// Lexing/unlexing text
function lextext(txt,cont) { gfshell('ps -lextext "'+txt+'"',cont) }
function unlextext(txt,cont) { gfshell('ps -bind -unlextext "'+txt+'"',cont) }

View File

@@ -1193,9 +1193,6 @@ function save_in_cloud(filename,document,cont) {
with_dir(save)
}
function unlextext(txt,cont) { gfshell('ps -bind -unlextext "'+txt+'"',cont) }
function lextext(txt,cont) { gfshell('ps -lextext "'+txt+'"',cont) }
// Like lextext, but separate punctuation from the end
function lexgfrobust(txt,cont) {
function rmpunct(txt) {

92
src/www/wc.html Normal file
View File

@@ -0,0 +1,92 @@
<!DOCTYPE html>
<html> <head>
<title>Demo: GF Wide Coverage Translation</title>
<link rel="stylesheet" type="text/css" href="gfse/editor.css" title="Cloud">
<meta name = "viewport" content = "width = device-width">
<meta charset="UTF-8">
<link rel=top href="../" title="GF">
<style>
div.center { text-align: center; }
table.center { margin-left: auto; margin-right: auto; }
textarea { margin: 0; }
body:target h1, body:target div.modtime { display: none; }
</style>
</head>
<body id=embed>
<div class=center>
<h1><a href="http://www.grammaticalframework.org/"><img class=nofloat src="P/gf-cloud.png" alt="GF"></a> Wide Coverage Translation</h1>
</div>
<table class="center">
<tr><td>
<form onsubmit="return wctranslate()">
<textarea name=input rows=3 style="width: 100%"></textarea>
<br>
<big></big>
<select name=from>
<option value=Bul>Bulgarian</option>
<option value=Chi>Chinese</option>
<option value=Eng selected>English</option>
<option value=Fin>Finnish</option>
<option value=Fre>French</option>
<option value=Ger>German</option>
<option value=Hin>Hindi</option>
<option value=Swe>Swedish</option>
</select>
<button name=translate type=submit><strong><big>Translate</big></strong></button>
<select name=to onchange="wctranslate()">
<option value=Bul>Bulgarian</option>
<option value=Chi>Chinese</option>
<option value=Eng>English</option>
<option value=Fin>Finnish</option>
<option value=Fre>French</option>
<option value=Ger>German</option>
<option value=Hin>Hindi</option>
<option value=Swe selected>Swedish</option>
</select>
<big style="position: relative; top: 1ex"></big>
  <button onclick="wcswap()">↑↓</button>
<br>
<textarea name=output rows=3 style="width: 100%" readonly></textarea>
</form>
</table>
<p>
<div class=modtime><small>
<!-- hhmts start -->Last modified: Tue Jan 28 17:38:32 CET 2014 <!-- hhmts end -->
</small></div>
<script src="js/support.js"></script>
<script src="js/gftranslate.js"></script>
<script src="js/localstorage.js"></script>
<script src="gfse/localstorage.js"></script>
<script src="gfse/cloud2.js"></script>
<script>
function wctranslate() {
var f=document.forms[0]
f.translate.disabled=true
f.output.value=""
function showit(result) {
f.output.value=result
f.translate.disabled=false
}
function step3(text) { unlextext(text,showit) }
function step2(text) {
gftranslate.translate(text,f.from.value,f.to.value,step3)
}
lextext(f.input.value,step2)
return false;
}
function wcswap() {
var f=document.forms[0]
f.input.value=f.output.value;
var from=f.from.value
f.from.value=f.to.value
f.to.value=from
wctranslate()
}
</script>
</body>
</html>