Skip to content

Commit

Permalink
asserting if Metamap binary path is not absolute. This handles issue A…
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushikacharya committed Jul 21, 2018
1 parent f43dd3b commit 4910df4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pymetamap/MetaMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
# limitations under the License.

import abc
from os.path import isabs

DEFAULT_METAMAP_VERSION = '2012'


class MetaMap:
""" Abstract base class for extracting concepts from text using
MetaMap. To use this you will need to have downloaded the
Expand All @@ -23,8 +25,10 @@ class MetaMap:
Subclasses need to override the extract_concepts method.
"""
__metaclass__ = abc.ABCMeta

def __init__(self, metamap_filename, version=None):
self.metamap_filename = str(metamap_filename)
assert isabs(self.metamap_filename), "metamap_filename: {0} should be absolute path".format(self.metamap_filename)
if version is None:
version = DEFAULT_METAMAP_VERSION

Expand All @@ -38,6 +42,7 @@ def extract_concepts(self, sentences=None, ids=None,
def get_instance(metamap_filename, version=None, backend='subprocess',
**extra_args):
extra_args.update(metamap_filename=metamap_filename, version=version)
assert isabs(metamap_filename), "metamap_filename: {0} should be absolute path".format(metamap_filename)

if backend == 'subprocess':
from .SubprocessBackend import SubprocessBackend
Expand Down

0 comments on commit 4910df4

Please sign in to comment.