WIP: new way for making empty objects (sense, translation,...)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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= []
|
||||
|
||||
@@ -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 = {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user