redid constructors and some other stuff in examples
this is preparation for ske implementation.
This commit is contained in:
@@ -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 = ""
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user