From d62b5b8cb678cb962b2f3be8104aa173ad45ec15 Mon Sep 17 00:00:00 2001 From: Alistair Johnson Date: Wed, 20 Feb 2019 12:03:24 -0500 Subject: [PATCH 1/2] fix return on bad parse to be None, None --- negbio/pipeline/ptb2ud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/negbio/pipeline/ptb2ud.py b/negbio/pipeline/ptb2ud.py index 8f35265..266939b 100644 --- a/negbio/pipeline/ptb2ud.py +++ b/negbio/pipeline/ptb2ud.py @@ -174,7 +174,7 @@ def convert_dg(dependency_graph, text, offset, ann_index=0, rel_index=0, has_lem if index == -1: logging.debug('Cannot convert parse tree to dependency graph at %d\n%d\n%s', start, offset, str(dependency_graph)) - return + return None, None ann = bioc.BioCAnnotation() ann.id = 'T{}'.format(ann_index) From 38ef8fa3da74706a46e8f1527adfb8d912e1fe07 Mon Sep 17 00:00:00 2001 From: Alistair Johnson Date: Wed, 20 Feb 2019 13:17:28 -0500 Subject: [PATCH 2/2] fix os.expanduser not handling pathlib2 path properly --- negbio/pipeline/parse.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/negbio/pipeline/parse.py b/negbio/pipeline/parse.py index c84bda0..e873293 100644 --- a/negbio/pipeline/parse.py +++ b/negbio/pipeline/parse.py @@ -14,6 +14,9 @@ def __init__(self, model_dir=None): logging.debug("downloading GENIA+PubMed model if necessary ...") model_dir = ModelFetcher.download_and_install_model( 'GENIA+PubMed', os.path.join(tempfile.gettempdir(), 'models')) + elif 'pathlib' in str(type(model_dir)): + # avoid python 2/3 compatibility issues with os/pathlib2 + model_dir = str(model_dir) self.model_dir = os.path.expanduser(model_dir) logging.debug('loading model %s ...' % self.model_dir)