mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
initial adaptation to the new runtime
This commit is contained in:
@@ -332,27 +332,4 @@ See the source code for details.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
==Commands that use the C run-time system==
|
||||
|
||||
GF includes two implementations of the PGF API: the traditional
|
||||
Haskell implementation and the newer C implementation. The commands documented
|
||||
above all use the Haskell implementation.
|
||||
The following commands use the C implementation instead:
|
||||
|
||||
- ``c-parse``, ``c-linearize``, ``c-linearizeAll``, ``c-translate``,
|
||||
``c-lookupmorpho``, ``c-flush``, ``c-grammar``, ``c-abstrtree``,
|
||||
``c-parsetree``, ``c-wordforword``.
|
||||
|
||||
|
||||
They implement the same functionality as the corresponding commands
|
||||
without the ``c-`` prefix, although there are some restrictions in what
|
||||
parameters they support, and some differences in the JSON
|
||||
data structures they output.
|
||||
|
||||
When using these commands, the grammar will be loaded and cached
|
||||
by the C run-time system. If you use commands from both the Haskell and C
|
||||
implementations with the same grammar, the grammar will be loaded twice.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
[www.grammaticalframework.org http://www.grammaticalframework.org]
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<li><a href="gfse/">GF online editor for simple multilingual grammars</a>
|
||||
<li><a href="translator/">Simple Translation Tool</a>
|
||||
(bilingual document editor)
|
||||
<!--<li><a href="wc.html">Wide Coverage Translation Demo</a>-->
|
||||
<li><a href="wc.html">Wide Coverage Translation Demo</a>
|
||||
<li><a href="gfmorpho/">Word inflection with smart paradigms</a>
|
||||
<li><a href="wordnet/">GF WordNet</a> (an online browser and editor for the WordNet lexicon)</li>
|
||||
</ul>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
var gftranslate = {}
|
||||
|
||||
gftranslate.jsonurl="/robust/App16.pgf"
|
||||
gftranslate.grammar="App" // the name of the grammar
|
||||
gftranslate.jsonurl="/robust/Parse.ngf"
|
||||
gftranslate.grammar="Parse" // the name of the grammar
|
||||
|
||||
gftranslate.documented_classes=
|
||||
["N", "N2", "N3", "A", "A2", "V", "V2", "VV", "VS", "VQ", "VA", "V3", "V2V",
|
||||
@@ -67,31 +67,12 @@ gftranslate.translate=function(source,from,to,start,limit,cont) {
|
||||
var too_long=check_limit(from,source)
|
||||
if(too_long) cont([{error:too_long}])
|
||||
else
|
||||
gftranslate.call("?command=c-translate&jsontree=true&input="
|
||||
gftranslate.call("?command=translate&jsontree=true&input="
|
||||
+encodeURIComponent(source)
|
||||
+lexer+"&unlexer=text&from="+g+from+"&to="+enc_langs(g,to)
|
||||
+"&start="+start+"&limit="+limit,extract,errcont)
|
||||
}
|
||||
|
||||
// Translate a sentence word for word (if all else fails...)
|
||||
gftranslate.wordforword=function(source,from,to,cont) {
|
||||
var g=gftranslate.grammar
|
||||
var lexer="&lexer=text"
|
||||
if(from=="Chi") lexer="",source=source.split("").join(" ")
|
||||
function errcont(text,code) { cont([{error:code+" "+text}]) }
|
||||
function extract(result) {
|
||||
cont(unspace_translations(g,result[0].translations))
|
||||
}
|
||||
var enc_to = enc_langs(g,to)
|
||||
var too_long=check_limit(from,source)
|
||||
if(too_long) cont([{error:too_long}])
|
||||
else
|
||||
gftranslate.call("?command=c-wordforword&input="
|
||||
+encodeURIComponent(source)
|
||||
+lexer+"&unlexer=text&from="+g+from+"&to="+enc_to
|
||||
,extract,errcont)
|
||||
}
|
||||
|
||||
// Get list of supported languages
|
||||
gftranslate.waiting=[]
|
||||
gftranslate.get_languages=function(cont,errcont) {
|
||||
@@ -118,7 +99,7 @@ gftranslate.get_languages=function(cont,errcont) {
|
||||
else {
|
||||
gftranslate.waiting.push({cont:cont,errcont:errcont})
|
||||
if(gftranslate.waiting.length<2)
|
||||
gftranslate.call("?command=c-grammar",init2,init2error)
|
||||
gftranslate.call("?command=grammar",init2,init2error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -214,29 +214,13 @@ wc.translate=function(redo) {
|
||||
//disable(false)
|
||||
}
|
||||
|
||||
function word_for_word(text,cont) {
|
||||
function step3(tra) {
|
||||
if(tra.length>=1) {
|
||||
var r=tra[0]
|
||||
r.prob = -1
|
||||
if(r.linearizations) showit(r,gftranslate.grammar)
|
||||
else if(r.error!=undefined)
|
||||
show_error(r.error)
|
||||
}
|
||||
else if(so.rs.length==0)
|
||||
show_error("Unable to translate")
|
||||
}
|
||||
gftranslate.wordforword(text,f.from.value,wc.languages || f.to.value,step3)
|
||||
}
|
||||
|
||||
function trans(text,i,count) {
|
||||
function step3(tra) {
|
||||
if(tra.length>=1) {
|
||||
var r=tra[0]
|
||||
if(r.error!=undefined) {
|
||||
if(i==0 && so.rs.length==0) {
|
||||
//show_error(r.error)
|
||||
word_for_word(text)
|
||||
show_error(r.error)
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user