Skip to content

Commit 2acf197

Browse files
committed
write.CorefHtml allow showing sent_id even if show_trees=False
1 parent e0573b5 commit 2acf197

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

udapi/block/write/corefhtml.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@
130130
var docs_loaded = 1;
131131
var load_fail_reported = false;
132132
var loading_now = false;
133-
add_show_tree_button = function(index, el){ } // to be redefined later if show_trees=True
133+
add_show_tree_button = function(index, el){ // to be redefined later if show_trees=True
134+
$(el).prepend('<span class="sent_id">🆔' + el.dataset.id + '</span>');
135+
}
134136
function load_more() {
135137
if (!loading_now && $(window).scrollTop() >= $(document).height() - $(window).height() - 42 && docs_loaded < all_docs) {
136138
docs_loaded += 1;
@@ -182,8 +184,6 @@
182184
})
183185
);
184186
}
185-
186-
$("#doc1 .sentence").each(add_show_tree_button);
187187
'''
188188

189189
WRITE_HTML = udapi.block.write.html.Html()
@@ -213,7 +213,7 @@ def __init__(self, docs_dir='docs', path_to_js='web',
213213
def _representative_word(self, entity):
214214
# return the first PROPN or NOUN. Or the most frequent one?
215215
heads = [m.head for m in entity.mentions]
216-
lemma_or_form = lambda n: n.lemma if n.lemma else n.form
216+
lemma_or_form = lambda n: n.lemma if n.lemma and n.lemma != '_' else n.form
217217
for upos in ('PROPN', 'NOUN'):
218218
nodes = [n for n in heads if n.upos == upos]
219219
if nodes:
@@ -292,7 +292,7 @@ def process_document(self, doc):
292292
f' <input id="show-eid" type="checkbox" {"checked" if self.show_eid else ""} onclick="$(\'.eid\').toggle(this.checked);"><label for="show-eid">eid</label><br>\n'
293293
f' <input id="show-etype" type="checkbox" {"checked" if self.show_etype else ""} onclick="$(\'.etype\').toggle(this.checked);"><label for="show-etype">etype</label><br>\n'
294294
' <input id="show-sent_id" type="checkbox" onclick="$(\'.sent_id\').toggle(this.checked);"><label for="show-sent_id">sent_id</label><br>\n'
295-
' <input id="show-trees" type="checkbox" checked onclick="$(\'.showtree\').toggle(this.checked);"><label for="show-trees">trees</label><br>\n'
295+
+ (' <input id="show-trees" type="checkbox" checked onclick="$(\'.showtree\').toggle(this.checked);"><label for="show-trees">trees</label><br>\n' if self.show_trees else '') +
296296
' <input id="show-color" type="checkbox" checked onclick="$(\'.m\').toggleClass(\'nocolor\',!this.checked);"><label for="show-color">colors</label><br>\n'
297297
' <input id="show-boxes" type="checkbox" checked onclick="$(\'.m\').toggleClass(\'nobox\',!this.checked);"><label for="show-boxes">boxes</label></div><div>\n'
298298
' <input id="show-norm" type="checkbox" checked onclick="$(\'.norm\').toggle(this.checked);"><label for="show-norm">non-mentions</label><br>\n'
@@ -337,6 +337,7 @@ def process_document(self, doc):
337337
finally:
338338
sys.stdout = orig_stdout
339339
print(SCRIPT_SHOWTREE)
340+
print('$("#doc1 .sentence").each(add_show_tree_button);')
340341
print('</script>')
341342
print('</div></body></html>')
342343

0 commit comments

Comments
 (0)