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 4e6db5d621
commit f1c4b353e3
4 changed files with 50 additions and 25 deletions

View File

@@ -3,7 +3,7 @@ Powered by multilingual grammars
%!style:../css/style.css %!style:../css/style.css
%!postproc(html): <H1> <H1><a href="../"><IMG src="../doc/Logos/gf0.svg" alt=""></a> %!postproc(html): <H1> <H1><a href="../"><IMG src="../doc/Logos/gf0.svg" alt=""></a>
%!postproc(html): #GFWCT <iframe style="border: 0; width: 100%; height: 24ex;" src="wc.html"></iframe> %!postproc(html): #GFWCT <iframe style="border: 0; width: 100%; height: 24ex;" src="http://cloud.grammaticalframework.org/wc.html#embed"></iframe>
==Try it online== ==Try it online==

View File

@@ -272,3 +272,7 @@ function check_exp(s,cont) {
} }
gfshell("cc "+s,check); 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) 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 // Like lextext, but separate punctuation from the end
function lexgfrobust(txt,cont) { function lexgfrobust(txt,cont) {
function rmpunct(txt) { function rmpunct(txt) {

View File

@@ -1,21 +1,27 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <head> <html> <head>
<title>Demo: GF Wide Coverage Translation</title> <title>Demo: GF Wide Coverage Translation</title>
<link rel=stylesheet href="../css/style.css"> <link rel="stylesheet" type="text/css" href="gfse/editor.css" title="Cloud">
<meta name = "viewport" content = "width = device-width"> <meta name = "viewport" content = "width = device-width">
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel=top href="../" title="GF"> <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> </head>
<body> <body id=embed>
<div style="display: none">
<h1><a href="../"><img class=nofloat style="height: 3ex" src="../doc/Logos/gf0.png" alt="GF"></a>
Wide Coverage Translation</h1>
</div>
<form onsubmit="return wctranslate()">
<div class=center> <div class=center>
<p> <h1><a href="http://www.grammaticalframework.org/"><img class=nofloat src="P/gf-cloud.png" alt="GF"></a> Wide Coverage Translation</h1>
<textarea name=input rows=3 cols=50></textarea> </div>
<table class="center">
<tr><td>
<form onsubmit="return wctranslate()">
<textarea name=input rows=3 style="width: 100%"></textarea>
<br> <br>
<big></big> <big></big>
<select name=from> <select name=from>
@@ -29,7 +35,7 @@ Wide Coverage Translation</h1>
<option value=Swe>Swedish</option> <option value=Swe>Swedish</option>
</select> </select>
<button name=translate type=submit><strong><big>Translate</big></strong></button> <button name=translate type=submit><strong><big>Translate</big></strong></button>
<select name=to> <select name=to onchange="wctranslate()">
<option value=Bul>Bulgarian</option> <option value=Bul>Bulgarian</option>
<option value=Chi>Chinese</option> <option value=Chi>Chinese</option>
<option value=Eng>English</option> <option value=Eng>English</option>
@@ -40,29 +46,47 @@ Wide Coverage Translation</h1>
<option value=Swe selected>Swedish</option> <option value=Swe selected>Swedish</option>
</select> </select>
<big style="position: relative; top: 1ex"></big> <big style="position: relative; top: 1ex"></big>
  <button onclick="wcswap()">↑↓</button>
<br> <br>
<textarea name=output rows=3 cols=50 readonly></textarea> <textarea name=output rows=3 style="width: 100%" readonly></textarea>
</div>
</form> </form>
<div style="display: none" class=modtime><small> </table>
<!-- hhmts start -->Last modified: Thu Jan 23 15:22:27 CET 2014 <!-- hhmts end --> <p>
<div class=modtime><small>
<!-- hhmts start -->Last modified: Tue Jan 28 17:38:32 CET 2014 <!-- hhmts end -->
</small></div> </small></div>
<script src="../src/www/js/support.js"></script> <script src="js/support.js"></script>
<script src="../src/www/js/gftranslate.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> <script>
gftranslate.jsonurl="http://cloud.grammaticalframework.org/robust/Translate8.pgf"
function wctranslate() { function wctranslate() {
var f=document.forms[0] var f=document.forms[0]
f.translate.disabled=true
f.output.value=""
function showit(result) { function showit(result) {
f.output.value=result f.output.value=result
f.translate.disabled=false f.translate.disabled=false
} }
f.translate.disabled=true function step3(text) { unlextext(text,showit) }
f.output.value="" function step2(text) {
gftranslate.translate(f.input.value,f.from.value,f.to.value,showit) gftranslate.translate(text,f.from.value,f.to.value,step3)
}
lextext(f.input.value,step2)
return false; 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> </script>
</body> </body>
</html> </html>