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()
|
||||
|
||||
lex_left = ComponentLexeme()
|
||||
lex_left.text = example["left"]
|
||||
lex_left.text = example["left"].strip()
|
||||
lex_left.role = None
|
||||
|
||||
lex_mid = ComponentLexeme()
|
||||
lex_mid.text = example["mid"]
|
||||
lex_mid.role = "headword"
|
||||
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
|
||||
|
||||
new_example.components.extend([lex_left, lex_mid, lex_right])
|
||||
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
|
||||
|
||||
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):
|
||||
|
|
|
@ -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":
|
||||
|
|
Loading…
Reference in New Issue
Block a user