mirror of https://github.com/explosion/spaCy.git
Add load_lang_class() util function
This commit is contained in:
parent
614aa09582
commit
9a0d2fdef1
|
@ -15,8 +15,7 @@ def load(name, **overrides):
|
|||
meta = util.parse_package_meta(model_path)
|
||||
if 'lang' not in meta:
|
||||
raise IOError('No language setting found in model meta.')
|
||||
module = importlib.import_module('.%s' % meta['lang'], 'spacy')
|
||||
cls = getattr(module, module.__all__[0])
|
||||
cls = util.load_lang_class(meta['lang'])
|
||||
overrides['meta'] = meta
|
||||
overrides['path'] = model_path
|
||||
return cls(**overrides)
|
||||
|
|
|
@ -31,6 +31,11 @@ def get_lang_class(name):
|
|||
return LANGUAGES[lang]
|
||||
|
||||
|
||||
def load_lang_class(lang, depth='.'):
|
||||
module = importlib.import_module('.lang.%s' % lang, 'spacy')
|
||||
return getattr(module, module.__all__[0])
|
||||
|
||||
|
||||
def get_data_path(require_exists=True):
|
||||
if not require_exists:
|
||||
return _data_path
|
||||
|
|
Loading…
Reference in New Issue