import pathlib

from .util import set_lang_class, get_lang_class

from . import en
from . import de
from . import zh


try:
    basestring
except NameError:
    basestring = str



set_lang_class(en.English.lang, en.English)
set_lang_class(de.German.lang, de.German)
set_lang_class(zh.Chinese.lang, zh.Chinese)


def load(name, **overrides):
    target_name, target_version = util.split_data_name(name)
    path = overrides.get('path', util.get_data_path())
    path = util.match_best_version(target_name, target_version, path)

    if isinstance(overrides.get('vectors'), basestring):
        vectors = util.match_best_version(overrides.get('vectors'), None, path)
    
    cls = get_lang_class(target_name)
    return cls(path=path, **overrides)

import pathlib

from .util import set_lang_class, get_lang_class

from . import en
from . import de
from . import zh


try:
    basestring
except NameError:
    basestring = str



set_lang_class(en.English.lang, en.English)
set_lang_class(de.German.lang, de.German)
set_lang_class(zh.Chinese.lang, zh.Chinese)


def load(name, **overrides):
    target_name, target_version = util.split_data_name(name)
    path = overrides.get('path', util.get_data_path())
    path = util.match_best_version(target_name, target_version, path)

    if isinstance(overrides.get('vectors'), basestring):
        vectors_path = util.match_best_version(overrides.get('vectors'), None, path)
        overrides['vectors'] = lambda nlp: nlp.vocab.load_vectors_from_bin_loc(
                                                vectors_path / 'vocab' / 'vec.bin')
    
    cls = get_lang_class(target_name)
    return cls(path=path, **overrides)

Fix mistake loading GloVe vectors. GloVe vectors now loaded by default if present, as promised.
Fix mistake loading GloVe vectors. GloVe vectors now loaded by default if present, as promised.

  import pathlib
  
  from .util import set_lang_class, get_lang_class
  
  from . import en
  from . import de
  from . import zh
  
  
  try:
      basestring
  except NameError:
      basestring = str
  
  
  
  set_lang_class(en.English.lang, en.English)
  set_lang_class(de.German.lang, de.German)
  set_lang_class(zh.Chinese.lang, zh.Chinese)
  
  
  def load(name, **overrides):
      target_name, target_version = util.split_data_name(name)
      path = overrides.get('path', util.get_data_path())
      path = util.match_best_version(target_name, target_version, path)
  
      if isinstance(overrides.get('vectors'), basestring):
-         vectors = util.match_best_version(overrides.get('vectors'), None, path)
+         vectors_path = util.match_best_version(overrides.get('vectors'), None, path)
+         overrides['vectors'] = lambda nlp: nlp.vocab.load_vectors_from_bin_loc(
+                                                 vectors_path / 'vocab' / 'vec.bin')
      
      cls = get_lang_class(target_name)
      return cls(path=path, **overrides)
  
Fix mistake loading GloVe vectors. GloVe vectors now loaded by default if present, as promised.
## Code Before:
import pathlib

from .util import set_lang_class, get_lang_class

from . import en
from . import de
from . import zh


try:
    basestring
except NameError:
    basestring = str



set_lang_class(en.English.lang, en.English)
set_lang_class(de.German.lang, de.German)
set_lang_class(zh.Chinese.lang, zh.Chinese)


def load(name, **overrides):
    target_name, target_version = util.split_data_name(name)
    path = overrides.get('path', util.get_data_path())
    path = util.match_best_version(target_name, target_version, path)

    if isinstance(overrides.get('vectors'), basestring):
        vectors = util.match_best_version(overrides.get('vectors'), None, path)
    
    cls = get_lang_class(target_name)
    return cls(path=path, **overrides)

## Instruction:
Fix mistake loading GloVe vectors. GloVe vectors now loaded by default if present, as promised.
## Code After:
import pathlib

from .util import set_lang_class, get_lang_class

from . import en
from . import de
from . import zh


try:
    basestring
except NameError:
    basestring = str



set_lang_class(en.English.lang, en.English)
set_lang_class(de.German.lang, de.German)
set_lang_class(zh.Chinese.lang, zh.Chinese)


def load(name, **overrides):
    target_name, target_version = util.split_data_name(name)
    path = overrides.get('path', util.get_data_path())
    path = util.match_best_version(target_name, target_version, path)

    if isinstance(overrides.get('vectors'), basestring):
        vectors_path = util.match_best_version(overrides.get('vectors'), None, path)
        overrides['vectors'] = lambda nlp: nlp.vocab.load_vectors_from_bin_loc(
                                                vectors_path / 'vocab' / 'vec.bin')
    
    cls = get_lang_class(target_name)
    return cls(path=path, **overrides)
