Clusters now as multipledigit number, correct-er numbering and some removal

This commit is contained in:
Ozbolt Menegatti 2020-02-01 21:43:57 +01:00
parent cf7c8b610b
commit 9dd9ac7854
6 changed files with 17 additions and 20 deletions

View File

@ -30,6 +30,8 @@ class Entry(Editable):
self.measure["text"] = measure.textContent
self.labels = import_label_list("head labelList label", entry_xml)
Sense.reset_cluster_count()
self.senses = [Sense(sense_xml) for sense_xml in
entry_xml.querySelectorAll("body senseList sense")]

View File

@ -106,8 +106,7 @@ class MultiwordExample:
for key, value in self.other_attributes.items():
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:
result.setAttribute("type", self.type)

View File

@ -44,3 +44,8 @@ class Sense(Editable):
return sorted(result)
@staticmethod
def reset_cluster_count():
global cluster_min
cluster_min = 0

View File

@ -109,14 +109,6 @@ def do_chosen_examples(example_list, entry):
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")]
for idx, sense in enumerate(entry.senses):
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("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))

View File

@ -2,9 +2,12 @@ from export import export_to_xml
from browser import window
from lib.snabbdom import h
import message
from math import log10
NUM2STR = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
def num2str(x):
return str(int(log10(x)) + 1)
def show_toggle_cluster_buttons(sense, example):
cls = example.get_cluster()
@ -17,8 +20,11 @@ def show_toggle_cluster_buttons(sense, example):
if opt == cls:
tag += ".cluster-button-checked"
attrs = {"value": str(opt + 1), "type": "button"}
style = {"width": num2str(opt + 1) + "em"}
result.append(h(tag,
{"attrs": {"value": NUM2STR[opt], "type": "button"},
{"attrs": attrs, "style": style,
"on": {"click": message.msg(message.ExampleClusterEdit(example, opt))}}, []))
return result

View File

@ -121,7 +121,7 @@ class View:
example_content = []
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_content.append(h(example_text_inner_tag, {}, example.text()))