lk_multiword_example #16
|
@ -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):
|
||||
|
@ -297,7 +318,7 @@ class SkeInsert(DataChgClickMessage):
|
|||
new_collocation.inner.other_attributes["frequency"] = example.frequency
|
||||
new_collocation.inner.type = "collocation"
|
||||
|
||||
headword = document.getElementById("ske-search").value
|
||||
headword = document.getElementById("ske-search").value
|
||||
lexemes = []
|
||||
structure_name = example.structure_name.split("-")
|
||||
gramrel = example.gramrel.split("_")
|
||||
|
@ -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…
Reference in New Issue
Block a user