WIP: new way for making empty objects (sense, translation,...)

This commit is contained in:
2019-11-17 21:23:28 +01:00
parent 14655bd6cf
commit 3cfcef6253
5 changed files with 14 additions and 15 deletions

View File

@@ -1,3 +1,6 @@
empty_doc = __new__(DOMParser()).parseFromString("<empty />", "text/xml")
class Editable:
def make_copy(self):
# makes an internal copy of self
@@ -25,3 +28,6 @@ class Editable:
self._copy = None
@classmethod
def new_empty(cls):
return cls(empty_doc)

View File

@@ -24,11 +24,3 @@ class Sense(Editable):
self.translations = [[] for _ in range(max_num_cluster)]
for clusterNum, translation in translations:
self.translations[clusterNum - 1].append(translation)
class NewSense(Sense):
def __init__(self):
self.translations = []
self.labels = []
self.definition = []
self.examples= []

View File

@@ -6,7 +6,10 @@ TAGS = {
}
class Translation:
from model.editable import Editable
class Translation(Editable):
def __init__(self, translation_xml):
translation = translation_xml.querySelector("translation")
self.translation = translation.textContent if translation else ""
@@ -22,8 +25,4 @@ class Translation:
self.tags[t_type] = t_value
class NewTranslation(Translation):
def __init__(self):
self.translation = ""
self.tags = {}