add multiple hw comps in mw examlpe
This commit is contained in:
parent
208f5b0ee8
commit
77a1e632a2
|
@ -273,18 +273,39 @@ class SkeInsert(DataChgClickMessage):
|
||||||
new_example.inner.cluster = ExampleClusters.first_empty_cluster()
|
new_example.inner.cluster = ExampleClusters.first_empty_cluster()
|
||||||
|
|
||||||
lex_left = ComponentLexeme()
|
lex_left = ComponentLexeme()
|
||||||
lex_left.text = example["left"]
|
lex_left.text = example["left"].strip()
|
||||||
lex_left.role = None
|
lex_left.role = None
|
||||||
|
if lex_left.text != '' and lex_left.text != None:
|
||||||
lex_mid = ComponentLexeme()
|
lex_left.text += ' '
|
||||||
lex_mid.text = example["mid"]
|
|
||||||
lex_mid.role = "headword"
|
|
||||||
|
|
||||||
lex_right = ComponentLexeme()
|
lex_right = ComponentLexeme()
|
||||||
lex_right.text = example["right"]
|
lex_right.text = example["right"].strip()
|
||||||
lex_right.role = None
|
lex_right.role = None
|
||||||
|
|
||||||
|
if lex_right.text is not None and len(lex_right.text) > 0 and lex_right.text[0] not in ['.', ',', '!', '?', ';']:
|
||||||
|
lex_right.text = ' ' + lex_right.text
|
||||||
|
|
||||||
new_example.components.extend([lex_left, lex_mid, lex_right])
|
lex_mid = []
|
||||||
|
if len(example['mid'].strip().split(' ')) == 1:
|
||||||
|
lex_comp = ComponentLexeme()
|
||||||
|
lex_comp.text = example["mid"]
|
||||||
|
lex_comp.role = "headword"
|
||||||
|
lex_mid.append(lex_comp)
|
||||||
|
else:
|
||||||
|
for lex in example['mid'].strip().split(' '):
|
||||||
|
lex_comp = ComponentLexeme()
|
||||||
|
lex_comp.text = lex
|
||||||
|
lex_comp.role = "headword"
|
||||||
|
lex_mid.append(lex_comp)
|
||||||
|
lex_comp = ComponentLexeme()
|
||||||
|
lex_comp.text = ' '
|
||||||
|
lex_comp.role = None
|
||||||
|
lex_mid.append(lex_comp)
|
||||||
|
lex_mid.pop(-1)
|
||||||
|
|
||||||
|
new_example.components.append(lex_left)
|
||||||
|
new_example.components.extend(lex_mid)
|
||||||
|
new_example.components.append(lex_right)
|
||||||
return new_example
|
return new_example
|
||||||
|
|
||||||
def _as_multiword_example(self, example):
|
def _as_multiword_example(self, example):
|
||||||
|
|
|
@ -11,6 +11,7 @@ class ComponentLexeme(Data):
|
||||||
self.text = ""
|
self.text = ""
|
||||||
self.role = ""
|
self.role = ""
|
||||||
self.no_space = False
|
self.no_space = False
|
||||||
|
self.multiword = False
|
||||||
|
|
||||||
def import_xml(self, xml):
|
def import_xml(self, xml):
|
||||||
if xml.nodeName == "#text":
|
if xml.nodeName == "#text":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user