diff --git a/setup.py b/setup.py index 591e50bbc..7be26c413 100644 --- a/setup.py +++ b/setup.py @@ -72,7 +72,7 @@ MOD_NAMES = [ # which is really known only after finalize_options # http://stackoverflow.com/questions/724664/python-distutils-how-to-get-a-compiler-that-is-going-to-be-used compile_options = { - 'msvc': ['/Ox', '/EHsc', '/openmp'], + 'msvc': ['/Ox', '/EHsc'], 'mingw32' : ['-O3', '-Wno-strict-prototypes', '-Wno-unused-function'], 'other' : ['-O3', '-Wno-strict-prototypes', '-Wno-unused-function'] } @@ -85,6 +85,10 @@ link_options = { } +if os.environ.get('USE_OPENMP') == '1': + compile_options['msvc'].append('/openmp') + + if not sys.platform.startswith('darwin'): compile_options['other'].append('-fopenmp') link_options['other'].append('-fopenmp') @@ -189,7 +193,6 @@ def setup_package(): 'thinc>=5.0.0,<5.1.0', 'plac', 'six', - 'ujson', 'cloudpickle', 'sputnik>=0.9.2,<0.10.0'], classifiers=[ diff --git a/spacy/__init__.py b/spacy/__init__.py index 676659fdd..37e8b6c4f 100644 --- a/spacy/__init__.py +++ b/spacy/__init__.py @@ -1,11 +1,11 @@ from .util import set_lang_class, get_lang_class, get_package, get_package_by_name -from .en import English -from .de import German +from . import en +from . import de -set_lang_class(English.lang, English) -set_lang_class(German.lang, German) +set_lang_class(en.English.lang, en.English) +set_lang_class(de.German.lang, de.German) def load(name, vectors=None, via=None): diff --git a/spacy/about.py b/spacy/about.py index 6abcb5d94..dd74e5d8c 100644 --- a/spacy/about.py +++ b/spacy/about.py @@ -14,4 +14,3 @@ __models__ = { 'en': 'en>=1.1.0,<1.2.0', 'de': 'de>=1.0.0,<1.1.0', } -__default_lang__ = 'en' diff --git a/spacy/gold.pyx b/spacy/gold.pyx index 67716b0ab..12c18b1c4 100644 --- a/spacy/gold.pyx +++ b/spacy/gold.pyx @@ -1,7 +1,6 @@ import numpy import io import json -import ujson import random import re import os diff --git a/spacy/language.py b/spacy/language.py index 39f78713b..236a0db03 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -20,6 +20,7 @@ from .syntax.ner import BiluoPushDown from .syntax.arc_eager import ArcEager from . import util +from . import about from .attrs import TAG, DEP, ENT_IOB, ENT_TYPE, HEAD @@ -166,7 +167,7 @@ class Language(object): """ if package is None: if data_dir is None: - package = util.get_package_by_name() + package = util.get_package_by_name(about.__models__[self.lang]) else: package = util.get_package(data_dir) diff --git a/spacy/strings.pyx b/spacy/strings.pyx index c890cdd22..2e81bd87b 100644 --- a/spacy/strings.pyx +++ b/spacy/strings.pyx @@ -10,7 +10,10 @@ from preshed.maps cimport map_iter, key_t from .typedefs cimport hash_t -import ujson as json +try: + import ujson as json +except ImportError: + import json cpdef hash_t hash_string(unicode string) except 0: diff --git a/spacy/tests/serialize/test_packer.py b/spacy/tests/serialize/test_packer.py index 392cba8e3..1f78da974 100644 --- a/spacy/tests/serialize/test_packer.py +++ b/spacy/tests/serialize/test_packer.py @@ -24,7 +24,7 @@ from spacy.serialize.bits import BitArray def vocab(): data_dir = os.environ.get('SPACY_DATA') if data_dir is None: - package = util.get_package_by_name() + package = util.get_package_by_name('en') else: package = util.get_package(data_dir) diff --git a/spacy/tests/tagger/test_lemmatizer.py b/spacy/tests/tagger/test_lemmatizer.py index af85645a6..aaf698fa3 100644 --- a/spacy/tests/tagger/test_lemmatizer.py +++ b/spacy/tests/tagger/test_lemmatizer.py @@ -14,7 +14,7 @@ import pytest def package(): data_dir = os.environ.get('SPACY_DATA') if data_dir is None: - return util.get_package_by_name() + return util.get_package_by_name('en') else: return util.get_package(data_dir) diff --git a/spacy/util.py b/spacy/util.py index b1e93d08b..8032cf6fd 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -36,11 +36,12 @@ def get_package(data_dir): def get_package_by_name(name=None, via=None): - package_name = name or about.__models__[about.__default_lang__] - lang = get_lang_class(package_name) + if name is None: + return + lang = get_lang_class(name) try: return sputnik.package(about.__title__, about.__version__, - package_name, data_path=via) + name, data_path=via) except PackageNotFoundException as e: raise RuntimeError("Model '%s' not installed. Please run 'python -m " "%s.download' to install latest compatible "