Skip to content

Commit

Permalink
#1238: API morphology update, split tuple.
Browse files Browse the repository at this point in the history
  • Loading branch information
susanodd committed May 30, 2024
1 parent ab0c72d commit c965323
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions signbank/gloss_morphology_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,33 +119,17 @@ def detect_type_related_problems_for_gloss_update(gloss, changes, language_code)

def gloss_update_do_changes(user, gloss, fields_to_update, language_code):
changes_done = []
for (field, new_value) in fields_to_update.items():
for field, (original_value, new_value) in fields_to_update.items():
if field == 'sequential_morphology':
morphemes = [get_default_annotationidglosstranslation(morpheme.morpheme)
for morpheme in MorphologyDefinition.objects.filter(parent_gloss=gloss)]
original_value = " + ".join(morphemes)
new_human_value_list = [v.strip() for v in new_value.split(' + ')]
# the new values have already been parsed at the previous stage
update_sequential_morphology(gloss, new_human_value_list)
changes_done.append((field, original_value, new_value))
elif field == 'simultaneous_morphology':
morphemes = [(get_default_annotationidglosstranslation(m.morpheme), m.role) for m in
gloss.simultaneous_morphology.all()]
sim_morphs = []
for m in morphemes:
sim_morphs.append(':'.join(m))
original_value = ','.join(sim_morphs)
new_human_value_list = [v.strip() for v in new_value.split(',')]
update_simultaneous_morphology(gloss, new_human_value_list)
changes_done.append((field, original_value, new_value))
elif field == 'blend_morphology':
morphemes = [(get_default_annotationidglosstranslation(m.glosses), m.role)
for m in gloss.blend_morphology.all()]

ble_morphs = []
for m in morphemes:
ble_morphs.append(':'.join(m))
original_value = ','.join(ble_morphs)
new_human_value_list = [v.strip() for v in new_value.split(',')]
update_blend_morphology(gloss, new_human_value_list)
changes_done.append((field, original_value, new_value))
Expand Down

0 comments on commit c965323

Please sign in to comment.