1
0
forked from GitHub/gf-core

PGF service & minibar: only show dependency diagrams if the labels are known

+ The PGF service now reads and caches dependency label configuration files.
+ The grammar info returned by command=grammar has a new boolean field 
  'hasDependencyLabels' to indicate if dependency labels were found for
  the grammar. Also, command=deptree will now fail if no labels are present.
+ The minibar only shows word dependency trees if labels are present.
+ Also changed the type of getDepLabels from [String] -> Labels to
  String -> Labels, since all uses were in the form "getDepLabels . lines".
This commit is contained in:
hallgren
2016-06-09 13:12:14 +00:00
parent 14f85ae06e
commit 674b14a832
6 changed files with 61 additions and 44 deletions

View File

@@ -135,7 +135,7 @@ Translations.prototype.show_translations=function(translationResults) {
var ts = text_speech(langcode,to,txt,lin)
var as = wrap("span",
self.options.show_trees
? [self.parsetree_button(tree,to),text(" "),ts]
? [self.parsetree_button(tree,to,self.grammar),text(" "),ts]
: [ts])
as.active=txt
as.swap=ts
@@ -225,7 +225,7 @@ Translations.prototype.show_translations=function(translationResults) {
var hdr=title("Switch input language to "+langcode,
button(langcode,act(lin[i])))
//hdr.disabled=lin[i].to==current.from
var btn=parsetree_button(t.tree,lin[i].to)
var btn=parsetree_button(t.tree,lin[i].to,grammar)
tbody.appendChild(
tr([th(hdr),show_lin(langcode,lin[i],t.tree)]));
}
@@ -288,14 +288,14 @@ Translations.prototype.alignment_button=function(abs,all,toLangs) {
return i;
}
Translations.prototype.parsetree_button=function(abs,lang) {
Translations.prototype.parsetree_button=function(abs,lang,grammar) {
var f=this.options.tree_img_format;
var img=this.server.current_grammar_url
+"?command=parsetree&format="+f+"&nodep=true&nodefont=arial"
+"&from="+lang+"&tree="+encodeURIComponent(abs);
var img_nofun=img+"&nofun=true"
var help="Click again to display parse tree. Click again to show function names."
if(f=="svg") {
if(f=="svg" && grammar.hasDependencyLabels) {
var depimg=this.server.current_grammar_url
+"?command=deptree&format=svg&to="+lang
+"&tree="+encodeURIComponent(abs);