redid constructors and some other stuff in examples

this is preparation for ske implementation.
This commit is contained in:
2020-03-30 20:31:59 +02:00
parent fc35a3079b
commit 49875416b2
5 changed files with 19 additions and 13 deletions

View File

@@ -1,7 +1,7 @@
from model.data import Data
class ComponentLexeme(Data):
def __init__(self, xml):
def __init__(self):
self.other_attributes = {}
self.text = ""
self.role = ""

View File

@@ -1,8 +1,10 @@
from lib.snabbdom import h
class CorpusExample:
def __init__(self, example_xml):
def __init__(self):
self.other_attributes = {}
def import_xml(self, example_xml):
for oth_attr in ["example_id", "modified", "lexical_unit_id", "audio"]:
if example_xml.hasAttribute(oth_attr):
self.other_attributes[oth_attr] = example_xml.getAttribute(oth_attr)

View File

@@ -25,7 +25,8 @@ class Example(Data):
self.inner = CorpusExample(inner_xml)
else:
inner_xml = example_xml.querySelector("multiwordExample")
self.inner = MultiwordExample(inner_xml)
self.inner = MultiwordExample()
self.inner.import_xml(inner_xml)
for comp_xml in inner_xml.childNodes:
comp = ComponentLexeme()

View File

@@ -4,6 +4,10 @@ from model.example_clusters import ExampleClusters
class MultiwordExample:
def __init__(self, example_xml):
self.other_attributes = {}
self.cluster = -1
self.type = None
def import_xml(self, example_xml):
for oth_attr in ["lexical_unit_id", "structure_id", "structureName", "audio", "frequency", "logDice"]:
if example_xml.hasAttribute(oth_attr):
self.other_attributes[oth_attr] = example_xml.getAttribute(oth_attr)
@@ -12,8 +16,6 @@ class MultiwordExample:
if example_xml.hasAttribute("type"):
self.type = example_xml.getAttribute("type")
else:
self.type = None
@staticmethod
def _determine_cluster_number(example_xml):
@@ -21,7 +23,7 @@ class MultiwordExample:
return ExampleClusters.first_empty_cluster()
else:
cluster = int(example_xml.getAttribute("cluster"))
ExampleClusters.register_cluster(cluster)
ExampleClusters.register_index(cluster)
return cluster
def export(self, doc):