Addresc MISC error in ENG visualiztion - spaces in that column

This commit is contained in:
lkrsnik 2025-02-16 10:31:17 +01:00
parent 77b9ff72cb
commit 31b2da01cb

11
app.py
View File

@ -132,13 +132,22 @@ def create_app():
subtree_ids = subtree_ids.split('+')
for subtree_id in subtree_ids:
annodoc += f'# visual-style {subtree_id} bgColor:lightgreen\n'
# modify original conllu
with open(os.path.join('media', result_id, 'annodoc', sentence_id), 'r') as rf:
read_annodoc = rf.read()
sentences = parse(read_annodoc)
# delete `deps` column
for token in sentences[0]:
# delete `deps` column
token['deps'] = None
# delete spaces in MISC
if 'misc' in token and token['misc'] is not None:
print(token['misc'])
for k in token['misc'].keys():
if type(token['misc'][k]) == str:
token['misc'][k] = token['misc'][k].replace(' ', '_')
annodoc += sentences[0].serialize()
return {'annodoc': annodoc}