lk_multiword_example #16

Merged
lkavcic merged 3 commits from lk_multiword_example into master 2 years ago

@ -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):
@ -330,8 +351,12 @@ class SkeInsert(DataChgClickMessage):
lex.text = structure[i]
lex.role = "other"
elif structure[i][0] in ["S", "G", "P", "R"]:
lex.text = headword
lex.role = "headword"
for hw in headword.split(" "):
lex = ComponentLexeme()
lex.text = hw
lex.role = "headword"
lexemes.append(lex)
lexemes.pop(-1)
else:
lex.text = example.word
lex.role = "collocate"

Loading…
Cancel
Save