diff --git a/spacy/cli/init_model.py b/spacy/cli/init_model.py index 629fb92b8..5dbe39901 100644 --- a/spacy/cli/init_model.py +++ b/spacy/cli/init_model.py @@ -14,7 +14,7 @@ import zipfile from ._messages import Messages from ..vectors import Vectors -from ..errors import Warnings, user_warning +from ..errors import Errors, Warnings, user_warning from ..util import prints, ensure_path, get_lang_class try: @@ -114,8 +114,7 @@ def read_vectors(vectors_loc): pieces = line.rsplit(' ', vectors_data.shape[1]+1) word = pieces.pop(0) if len(pieces) != vectors_data.shape[1]: - print(word, repr(line)) - raise ValueError("Bad line in file") + raise ValueError(Errors.E094.format(line_num=i, loc=vectors_loc) vectors_data[i] = numpy.asarray(pieces, dtype='f') vectors_keys.append(word) return vectors_data, vectors_keys diff --git a/spacy/errors.py b/spacy/errors.py index 2713f76c8..b60fe690a 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -244,6 +244,7 @@ class Errors(object): "Alternatively, it is built from the 'lang' and 'name' keys in " "the meta.json. Vector names are required to avoid issue #1660.") E093 = ("token.ent_iob values make invalid sequence: I without B\n{seq}") + E094 = ("Error reading line {line_num} in vectors file {loc}.") @add_codes