_restore_from_ascii() method in metamap.py throws "TypeError: list indices must be integers not strings" when dealing with a converted document. #120

Closed
opened 2025-10-14 16:25:38 -06:00 by navan · 0 comments
Owner

Originally created by @CoreySutphin on 2/18/2019

Description

If a non-ascii character is actually converted, when the program goes to restore the non-ascii character in the _restore_from_ascii_ method in metamap.py, it throws a TypeError. The offending line is for mapping in metamap_dict['metamap']['MMOs']['MMO']['Utterances']['Utterance']['Phrases']['Phrase']['Mappings']['Mapping']:.

Steps/Code to Reproduce

Include a character such as л in your document and attempt to metamap. The error will be thrown when it attempts to restore the document back.

Expected Results

Text has non-ascii characters again and the character spans in the metamap dictionary are updated to reflect the restoration.

Actual Results

Error thrown.

Versions

Linux-4.15.0-43-generic-x86_64-with-Ubuntu-16.04-xenial
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
medacy 0.0.8

*Originally created by @CoreySutphin on 2/18/2019* #### Description If a non-ascii character is actually converted, when the program goes to restore the non-ascii character in the `_restore_from_ascii_` method in `metamap.py`, it throws a TypeError. The offending line is `for mapping in metamap_dict['metamap']['MMOs']['MMO']['Utterances']['Utterance']['Phrases']['Phrase']['Mappings']['Mapping']:`. #### Steps/Code to Reproduce Include a character such as л in your document and attempt to metamap. The error will be thrown when it attempts to restore the document back. #### Expected Results Text has non-ascii characters again and the character spans in the metamap dictionary are updated to reflect the restoration. #### Actual Results Error thrown. #### Versions <!-- Please run the following snippet and paste the output below. import platform; print(platform.platform()) import sys; print("Python", sys.version) import numpy; print("NumPy", numpy.__version__) import scipy; print("SciPy", scipy.__version__) import medacy; print("medacy", medacy.__version__) --> Linux-4.15.0-43-generic-x86_64-with-Ubuntu-16.04-xenial Python 3.5.2 (default, Nov 12 2018, 13:43:14) medacy 0.0.8 <!-- Thanks for contributing! -->
navan 2025-10-14 16:25:43 -06:00
  • closed this issue
  • added the
    bug
    label
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github/medaCy#120
No description provided.