mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 02:36:32 +03:00
return custom error in nlp.initialize (#7104)
* return custom error in nlp.initialize * Rename error Co-authored-by: Ines Montani <ines@ines.io>
This commit is contained in:
parent
3f3e8110dc
commit
39de3602e0
|
@ -497,6 +497,10 @@ class Errors:
|
||||||
E880 = ("The 'wandb' library could not be found - did you install it? "
|
E880 = ("The 'wandb' library could not be found - did you install it? "
|
||||||
"Alternatively, specify the 'ConsoleLogger' in the 'training.logger' "
|
"Alternatively, specify the 'ConsoleLogger' in the 'training.logger' "
|
||||||
"config section, instead of the 'WandbLogger'.")
|
"config section, instead of the 'WandbLogger'.")
|
||||||
|
E884 = ("The pipeline could not be initialized because the vectors "
|
||||||
|
"could not be found at '{vectors}'. If your pipeline was already "
|
||||||
|
"initialized/trained before, call 'resume_training' instead of 'initialize', "
|
||||||
|
"or initialize only the components that are new.")
|
||||||
E885 = ("entity_linker.set_kb received an invalid 'kb_loader' argument: expected "
|
E885 = ("entity_linker.set_kb received an invalid 'kb_loader' argument: expected "
|
||||||
"a callable function, but got: {arg_type}")
|
"a callable function, but got: {arg_type}")
|
||||||
E886 = ("Can't replace {name} -> {tok2vec} listeners: path '{path}' not "
|
E886 = ("Can't replace {name} -> {tok2vec} listeners: path '{path}' not "
|
||||||
|
|
|
@ -1219,9 +1219,12 @@ class Language:
|
||||||
before_init = I["before_init"]
|
before_init = I["before_init"]
|
||||||
if before_init is not None:
|
if before_init is not None:
|
||||||
before_init(self)
|
before_init(self)
|
||||||
|
try:
|
||||||
init_vocab(
|
init_vocab(
|
||||||
self, data=I["vocab_data"], lookups=I["lookups"], vectors=I["vectors"]
|
self, data=I["vocab_data"], lookups=I["lookups"], vectors=I["vectors"]
|
||||||
)
|
)
|
||||||
|
except IOError:
|
||||||
|
raise IOError(Errors.E884.format(vectors=I["vectors"]))
|
||||||
if self.vocab.vectors.data.shape[1] >= 1:
|
if self.vocab.vectors.data.shape[1] >= 1:
|
||||||
ops = get_current_ops()
|
ops = get_current_ops()
|
||||||
self.vocab.vectors.data = ops.asarray(self.vocab.vectors.data)
|
self.vocab.vectors.data = ops.asarray(self.vocab.vectors.data)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user