2017-03-16 16:13:08 +00:00
|
|
|
# coding: utf8
|
|
|
|
from __future__ import unicode_literals, print_function
|
|
|
|
|
|
|
|
import json
|
|
|
|
from pathlib import Path
|
|
|
|
from .util import set_lang_class, get_lang_class, parse_package_meta
|
2017-03-17 17:47:05 +00:00
|
|
|
from .deprecated import resolve_model_name
|
2017-03-22 09:02:14 +00:00
|
|
|
from .cli import info
|
2016-01-15 17:01:02 +00:00
|
|
|
|
2016-04-12 14:31:16 +00:00
|
|
|
from . import en
|
|
|
|
from . import de
|
2016-04-24 16:45:16 +00:00
|
|
|
from . import zh
|
2016-11-02 19:05:14 +00:00
|
|
|
from . import es
|
|
|
|
from . import it
|
2016-12-21 19:45:36 +00:00
|
|
|
from . import hu
|
2016-11-02 19:48:29 +00:00
|
|
|
from . import fr
|
2016-11-02 19:05:14 +00:00
|
|
|
from . import pt
|
2016-11-24 15:39:49 +00:00
|
|
|
from . import nl
|
2016-12-20 10:05:06 +00:00
|
|
|
from . import sv
|
2017-01-31 22:27:29 +00:00
|
|
|
from . import fi
|
2017-02-28 01:48:37 +00:00
|
|
|
from . import bn
|
2017-03-29 08:34:57 +00:00
|
|
|
from . import he
|
2016-03-24 10:19:43 +00:00
|
|
|
|
2017-03-18 18:30:03 +00:00
|
|
|
from .about import *
|
|
|
|
|
2017-03-15 16:33:57 +00:00
|
|
|
|
2016-04-12 14:31:16 +00:00
|
|
|
set_lang_class(en.English.lang, en.English)
|
|
|
|
set_lang_class(de.German.lang, de.German)
|
2016-11-02 19:05:14 +00:00
|
|
|
set_lang_class(es.Spanish.lang, es.Spanish)
|
|
|
|
set_lang_class(pt.Portuguese.lang, pt.Portuguese)
|
|
|
|
set_lang_class(fr.French.lang, fr.French)
|
|
|
|
set_lang_class(it.Italian.lang, it.Italian)
|
2016-12-07 22:07:43 +00:00
|
|
|
set_lang_class(hu.Hungarian.lang, hu.Hungarian)
|
2016-04-24 16:45:16 +00:00
|
|
|
set_lang_class(zh.Chinese.lang, zh.Chinese)
|
2016-11-29 15:42:05 +00:00
|
|
|
set_lang_class(nl.Dutch.lang, nl.Dutch)
|
2016-12-20 10:05:06 +00:00
|
|
|
set_lang_class(sv.Swedish.lang, sv.Swedish)
|
2017-01-31 22:27:29 +00:00
|
|
|
set_lang_class(fi.Finnish.lang, fi.Finnish)
|
2017-02-28 01:48:37 +00:00
|
|
|
set_lang_class(bn.Bengali.lang, bn.Bengali)
|
2017-03-29 08:34:57 +00:00
|
|
|
set_lang_class(he.Hebrew.lang, he.Hebrew)
|
2017-01-31 22:27:29 +00:00
|
|
|
|
2016-03-25 17:54:45 +00:00
|
|
|
|
2016-10-18 17:23:31 +00:00
|
|
|
def load(name, **overrides):
|
2016-10-20 16:27:48 +00:00
|
|
|
data_path = overrides.get('path', util.get_data_path())
|
2017-03-17 17:47:05 +00:00
|
|
|
model_name = resolve_model_name(name)
|
2017-03-17 18:51:45 +00:00
|
|
|
meta = parse_package_meta(data_path, model_name, require=False)
|
2017-03-16 23:30:02 +00:00
|
|
|
lang = meta['lang'] if meta and 'lang' in meta else name
|
2017-03-16 16:13:08 +00:00
|
|
|
cls = get_lang_class(lang)
|
|
|
|
overrides['meta'] = meta
|
2017-03-17 18:51:45 +00:00
|
|
|
model_path = Path(data_path / model_name)
|
2017-03-16 23:30:02 +00:00
|
|
|
if model_path.exists():
|
|
|
|
overrides['path'] = model_path
|
2017-03-17 18:51:45 +00:00
|
|
|
|
2016-12-18 21:15:29 +00:00
|
|
|
return cls(**overrides)
|