add multiple hw comps in mw examlpe

This commit is contained in:
Luka Kavčič 2022-02-05 11:14:42 +01:00
parent 208f5b0ee8
commit 77a1e632a2
2 changed files with 31 additions and 9 deletions

View File

@ -273,18 +273,39 @@ class SkeInsert(DataChgClickMessage):
new_example.inner.cluster = ExampleClusters.first_empty_cluster()
lex_left = ComponentLexeme()
lex_left.text = example["left"]
lex_left.role = None
lex_mid = ComponentLexeme()
lex_mid.text = example["mid"]
lex_mid.role = "headword"
lex_left.text = example["left"].strip()
lex_left.role = None
if lex_left.text != '' and lex_left.text != None:
lex_left.text += ' '
lex_right = ComponentLexeme()
lex_right.text = example["right"]
lex_right.text = example["right"].strip()
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
def _as_multiword_example(self, example):

View File

@ -11,6 +11,7 @@ class ComponentLexeme(Data):
self.text = ""
self.role = ""
self.no_space = False
self.multiword = False
def import_xml(self, xml):
if xml.nodeName == "#text":