From 0d7d50fe22d0b574f64e9d534b36cd7d30d10caa Mon Sep 17 00:00:00 2001 From: ines Date: Mon, 29 May 2017 20:43:24 +0200 Subject: [PATCH 1/3] Add __version__ to __init__.py --- spacy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacy/__init__.py b/spacy/__init__.py index 05822c177..9a1f8304e 100644 --- a/spacy/__init__.py +++ b/spacy/__init__.py @@ -4,9 +4,9 @@ from __future__ import unicode_literals from .cli.info import info as cli_info from .glossary import explain from .deprecated import resolve_load_name +from .about import __version__ from . import util - def load(name, **overrides): name = resolve_load_name(name, **overrides) return util.load_model(name, **overrides) From 6145fe6a93035f81eb39cb24d7a888160a27bc2f Mon Sep 17 00:00:00 2001 From: ines Date: Mon, 29 May 2017 20:43:48 +0200 Subject: [PATCH 2/3] Catch all kwargs on Language --- spacy/language.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacy/language.py b/spacy/language.py index 8f1ae69ca..d05100ae6 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -132,7 +132,7 @@ class Language(object): Defaults = BaseDefaults lang = None - def __init__(self, vocab=True, make_doc=True, pipeline=None, meta={}): + def __init__(self, vocab=True, make_doc=True, pipeline=None, meta={}, **kwargs): """Initialise a Language object. vocab (Vocab): A `Vocab` object. If `True`, a vocab is created via From 08382f21e30ffd38f5905764c01e2ae66787e3d0 Mon Sep 17 00:00:00 2001 From: ines Date: Mon, 29 May 2017 20:44:11 +0200 Subject: [PATCH 3/3] Pass model meta to nlp object in load_model --- spacy/util.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spacy/util.py b/spacy/util.py index 329c6ce88..00bc4e9fc 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -108,12 +108,12 @@ def load_model(name, **overrides): model_path = Path(name) meta = get_package_meta(model_path) cls = get_lang_class(meta['lang']) - nlp = cls(pipeline=meta.get('pipeline', True)) + nlp = cls(pipeline=meta.get('pipeline', True), meta=meta) return nlp.from_disk(model_path, **overrides) elif hasattr(name, 'exists'): # Path or Path-like to model data meta = get_package_meta(name) cls = get_lang_class(meta['lang']) - nlp = cls(pipeline=meta.get('pipeline', True)) + nlp = cls(pipeline=meta.get('pipeline', True), meta=meta) return nlp.from_disk(name, **overrides) raise IOError("Can't find model '%s'" % name) @@ -133,7 +133,7 @@ def load_model_from_init_py(init_file, **overrides): if not model_path.exists(): raise ValueError("Can't find model directory: %s" % path2str(data_path)) cls = get_lang_class(meta['lang']) - nlp = cls(pipeline=meta.get('pipeline', True)) + nlp = cls(pipeline=meta.get('pipeline', True), meta=meta) return nlp.from_disk(data_path, **overrides) @@ -461,7 +461,7 @@ def model_from_bytes(model, bytes_data): i += 1 if hasattr(layer, '_layers'): queue.extend(layer._layers) - + def print_table(data, title=None): """Print data in table format.