From 618b50a0641af668398975ef345884b7caabca82 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 18 Dec 2016 22:46:31 +0100 Subject: [PATCH 1/3] Fix issue #684: GloVe vectors not loaded in spacy.en.English. --- spacy/en/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spacy/en/__init__.py b/spacy/en/__init__.py index 55832543d..f2b269100 100644 --- a/spacy/en/__init__.py +++ b/spacy/en/__init__.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals, print_function from os import path from ..util import match_best_version +from ..util import get_data_path from ..language import Language from ..lemmatizer import Lemmatizer from ..vocab import Vocab @@ -37,10 +38,11 @@ def _fix_deprecated_glove_vectors_loading(overrides): if 'data_dir' in overrides and 'path' not in overrides: raise ValueError("The argument 'data_dir' has been renamed to 'path'") if overrides.get('path') is None: - return overrides - path = overrides['path'] - if 'add_vectors' not in overrides: + data_path = get_data_path() + else: + path = overrides['path'] data_path = path.parent + if 'add_vectors' not in overrides: if 'vectors' in overrides: vec_path = match_best_version(overrides['vectors'], None, data_path) if vec_path is None: From 2c6228565e5abb2727b71c360abb218514e252c5 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 18 Dec 2016 23:06:44 +0100 Subject: [PATCH 2/3] Fix vector loading re glove hack --- spacy/en/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacy/en/__init__.py b/spacy/en/__init__.py index f2b269100..68b694d42 100644 --- a/spacy/en/__init__.py +++ b/spacy/en/__init__.py @@ -52,5 +52,6 @@ def _fix_deprecated_glove_vectors_loading(overrides): vec_path = match_best_version('en_glove_cc_300_1m_vectors', None, data_path) if vec_path is not None: vec_path = vec_path / 'vocab' / 'vec.bin' - overrides['add_vectors'] = lambda vocab: vocab.load_vectors_from_bin_loc(vec_path) + if vec_path is not None: + overrides['add_vectors'] = lambda vocab: vocab.load_vectors_from_bin_loc(vec_path) return overrides From 13a0b312790749089e3db27b722b9365acedb931 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 18 Dec 2016 23:12:49 +0100 Subject: [PATCH 3/3] Another tweak to GloVe path hackery. --- spacy/en/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spacy/en/__init__.py b/spacy/en/__init__.py index 68b694d42..d4a371b2b 100644 --- a/spacy/en/__init__.py +++ b/spacy/en/__init__.py @@ -37,7 +37,9 @@ class English(Language): def _fix_deprecated_glove_vectors_loading(overrides): if 'data_dir' in overrides and 'path' not in overrides: raise ValueError("The argument 'data_dir' has been renamed to 'path'") - if overrides.get('path') is None: + if overrides.get('path') is False: + return overrides + if overrides.get('path') in (None, True): data_path = get_data_path() else: path = overrides['path']