Skip to content

Commit

Permalink
converting MetaMap returned output in bytes to str for common handlin…
Browse files Browse the repository at this point in the history
…g of python 2 and python 3. Resolves issue #9 raised on 11th Dec 2019. (#44)
  • Loading branch information
kaushikacharya authored and AnthonyMRios committed Jan 27, 2020
1 parent 89051be commit 2c9490f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pymetamap/SubprocessBackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import os
import subprocess
import sys
import tempfile
from .MetaMap import MetaMap
from .Concept import Corpus
Expand Down Expand Up @@ -171,6 +172,10 @@ def extract_concepts(self, sentences=None, ids=None,
metamap_process = subprocess.Popen(command, stdout=subprocess.PIPE, stdin=input_process.stdout)

output, error = metamap_process.communicate()
if sys.version_info[0] > 2:
if isinstance(output, bytes):
output = output.decode()

# "Processing" sentences are returned as stderr. Hence success/failure of metamap_process needs to be
# checked by its returncode.
if metamap_process.returncode == 0:
Expand Down

0 comments on commit 2c9490f

Please sign in to comment.