Clusters now as multipledigit number, correct-er numbering and some removal
This commit is contained in:
parent
cf7c8b610b
commit
9dd9ac7854
|
@ -30,6 +30,8 @@ class Entry(Editable):
|
||||||
self.measure["text"] = measure.textContent
|
self.measure["text"] = measure.textContent
|
||||||
|
|
||||||
self.labels = import_label_list("head labelList label", entry_xml)
|
self.labels = import_label_list("head labelList label", entry_xml)
|
||||||
|
|
||||||
|
Sense.reset_cluster_count()
|
||||||
self.senses = [Sense(sense_xml) for sense_xml in
|
self.senses = [Sense(sense_xml) for sense_xml in
|
||||||
entry_xml.querySelectorAll("body senseList sense")]
|
entry_xml.querySelectorAll("body senseList sense")]
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,6 @@ class MultiwordExample:
|
||||||
for key, value in self.other_attributes.items():
|
for key, value in self.other_attributes.items():
|
||||||
result.setAttribute(key, value)
|
result.setAttribute(key, value)
|
||||||
|
|
||||||
if self.cluster_valid:
|
|
||||||
result.setAttribute("cluster", str(self.cluster))
|
result.setAttribute("cluster", str(self.cluster))
|
||||||
|
|
||||||
if self.type is not None:
|
if self.type is not None:
|
||||||
|
|
|
@ -44,3 +44,8 @@ class Sense(Editable):
|
||||||
|
|
||||||
return sorted(result)
|
return sorted(result)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def reset_cluster_count():
|
||||||
|
global cluster_min
|
||||||
|
cluster_min = 0
|
||||||
|
|
||||||
|
|
|
@ -109,14 +109,6 @@ def do_chosen_examples(example_list, entry):
|
||||||
|
|
||||||
sense_of_first_example = example_senses[0]
|
sense_of_first_example = example_senses[0]
|
||||||
|
|
||||||
# determine if one can choose clusters
|
|
||||||
# this can happen ef every example from same sense and every example a collocation
|
|
||||||
can_choose_cluster = len(set(example_senses)) == 1
|
|
||||||
idx = 0
|
|
||||||
while can_choose_cluster and idx < len(example_list):
|
|
||||||
can_choose_cluster = example_list[idx].is_collocation()
|
|
||||||
idx += 1
|
|
||||||
|
|
||||||
options = [h("p", {}, "Choose sense for examples")]
|
options = [h("p", {}, "Choose sense for examples")]
|
||||||
for idx, sense in enumerate(entry.senses):
|
for idx, sense in enumerate(entry.senses):
|
||||||
text = "{}: {}".format(idx + 1, sense.definition["indicator"])
|
text = "{}: {}".format(idx + 1, sense.definition["indicator"])
|
||||||
|
@ -130,11 +122,4 @@ def do_chosen_examples(example_list, entry):
|
||||||
options.append(h("label.checkable", {"attrs": {"for": id_}}, text))
|
options.append(h("label.checkable", {"attrs": {"for": id_}}, text))
|
||||||
options.append(h("br", {}, []))
|
options.append(h("br", {}, []))
|
||||||
|
|
||||||
if can_choose_cluster:
|
|
||||||
options.append(h("hr", {}, []))
|
|
||||||
options.append(h("div.flex.five.example-component", {}, [
|
|
||||||
h("div.two-fifth", {}, "NOT IMPLEMENTED"),
|
|
||||||
h("div.three-fifth", {},
|
|
||||||
show_toggle_cluster_buttons(entry.senses[sense_of_first_example], example_list[0]))]))
|
|
||||||
|
|
||||||
return modal_template(options, "Examples picker", message.DoChosenExamples(example_list))
|
return modal_template(options, "Examples picker", message.DoChosenExamples(example_list))
|
||||||
|
|
|
@ -2,9 +2,12 @@ from export import export_to_xml
|
||||||
from browser import window
|
from browser import window
|
||||||
from lib.snabbdom import h
|
from lib.snabbdom import h
|
||||||
import message
|
import message
|
||||||
|
from math import log10
|
||||||
|
|
||||||
|
|
||||||
NUM2STR = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
def num2str(x):
|
||||||
|
return str(int(log10(x)) + 1)
|
||||||
|
|
||||||
|
|
||||||
def show_toggle_cluster_buttons(sense, example):
|
def show_toggle_cluster_buttons(sense, example):
|
||||||
cls = example.get_cluster()
|
cls = example.get_cluster()
|
||||||
|
@ -17,8 +20,11 @@ def show_toggle_cluster_buttons(sense, example):
|
||||||
if opt == cls:
|
if opt == cls:
|
||||||
tag += ".cluster-button-checked"
|
tag += ".cluster-button-checked"
|
||||||
|
|
||||||
|
attrs = {"value": str(opt + 1), "type": "button"}
|
||||||
|
style = {"width": num2str(opt + 1) + "em"}
|
||||||
|
|
||||||
result.append(h(tag,
|
result.append(h(tag,
|
||||||
{"attrs": {"value": NUM2STR[opt], "type": "button"},
|
{"attrs": attrs, "style": style,
|
||||||
"on": {"click": message.msg(message.ExampleClusterEdit(example, opt))}}, []))
|
"on": {"click": message.msg(message.ExampleClusterEdit(example, opt))}}, []))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ class View:
|
||||||
|
|
||||||
example_content = []
|
example_content = []
|
||||||
if cluster is not None:
|
if cluster is not None:
|
||||||
example_content.append(h("span.example-cluster", {}, NUM2STR[cluster]))
|
example_content.append(h("span.example-cluster", {}, num2str(cluster)))
|
||||||
|
|
||||||
example_text_inner_tag = "span.example-text-{}".format(example.get_view_type())
|
example_text_inner_tag = "span.example-text-{}".format(example.get_view_type())
|
||||||
example_content.append(h(example_text_inner_tag, {}, example.text()))
|
example_content.append(h(example_text_inner_tag, {}, example.text()))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user