Merge branch 'master' of ssh://github.com/honnibal/spaCy

This commit is contained in:
Matthew Honnibal 2016-04-14 10:37:56 +02:00
commit 0f957dd586
9 changed files with 21 additions and 15 deletions

View File

@ -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=[

View File

@ -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):

View File

@ -14,4 +14,3 @@ __models__ = {
'en': 'en>=1.1.0,<1.2.0',
'de': 'de>=1.0.0,<1.1.0',
}
__default_lang__ = 'en'

View File

@ -1,7 +1,6 @@
import numpy
import io
import json
import ujson
import random
import re
import os

View File

@ -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)

View File

@ -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:

View File

@ -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)

View File

@ -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)

View File

@ -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 "