summaryrefslogtreecommitdiff
path: root/src/www/gfmorpho/morpho.js
diff options
context:
space:
mode:
authorThomas Hallgren <th-github@altocumulus.org>2019-12-03 16:40:21 +0100
committerThomas Hallgren <th-github@altocumulus.org>2019-12-03 16:40:21 +0100
commitfb1199c49c39bd9dccde778d60ab50f42edd289f (patch)
treebba5940d8c4855928380cc1a44e7f077fc5accbb /src/www/gfmorpho/morpho.js
parent12e55c93c06263f7f042bc5d8a2c80d6e90b15fa (diff)
GF Cloud: add Word inflection with smart paradigms
This is a reimplemention of Aarne's GFMorpho service from 2012, using the GF shell web API. Not all features are implemented (yet).
Diffstat (limited to 'src/www/gfmorpho/morpho.js')
-rw-r--r--src/www/gfmorpho/morpho.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/www/gfmorpho/morpho.js b/src/www/gfmorpho/morpho.js
new file mode 100644
index 000000000..d154b8bf7
--- /dev/null
+++ b/src/www/gfmorpho/morpho.js
@@ -0,0 +1,42 @@
+
+var local=appLocalStorage("gf.morpho.")
+
+function quote(s) {
+ return s[0]=="_" ? s.substr(1) : '"'+s+'"'
+}
+
+function show_output(output) {
+ morpho_output.className=output ? "morpho_output" : ""
+ replaceChildren(morpho_output,text(output))
+}
+
+function submitmorpho() {
+ clear(morpho_output)
+ var args=morpho.args.value.split(/ +/)
+ var lang=args[0]
+ var cat=args[1]
+ var wordforms=args.slice(2).map(quote).join(" ")
+ //console.log("submitmorpho",lang,cat,wordforms)
+ switch("") {
+ case lang: show_output("No language"); break;
+ case cat: show_output("No category"); break;
+ case wordforms: show_output("No word forms"); break;
+ default:
+ gfshell("e",function() {
+ gfshell("i -retain alltenses/Paradigms"+lang+".gfo",function() {
+ gfshell("cc -table -unqual mk"+cat+wordforms,show_output)
+ })
+ })
+ }
+ return false;
+}
+
+function resetmorpho() {
+ show_output("")
+}
+
+function submit_example(b) {
+ //console.log("submit_example",b.value)
+ morpho.args.value=b.value
+ submitmorpho()
+}