Rephrase error about vocab methods for vectors

This commit is contained in:
Adriane Boyd 2023-08-01 08:34:05 +02:00
parent ffbc4af216
commit 8d6df674fa
2 changed files with 5 additions and 4 deletions

View File

@ -553,7 +553,8 @@ class Errors(metaclass=ErrorsWithCodes):
"during training, make sure to include it in 'annotating components'") "during training, make sure to include it in 'annotating components'")
# New errors added in v3.x # New errors added in v3.x
E849 = ("Unable to {action} vectors for vectors of type {vectors_type}.") E849 = ("The vocab only supports {method} for vectors of type "
"spacy.vectors.Vectors, not {vectors_type}.")
E850 = ("The PretrainVectors objective currently only supports default or " E850 = ("The PretrainVectors objective currently only supports default or "
"floret vectors, not {mode} vectors.") "floret vectors, not {mode} vectors.")
E851 = ("The 'textcat' component labels should only have values of 0 or 1, " E851 = ("The 'textcat' component labels should only have values of 0 or 1, "

View File

@ -300,7 +300,7 @@ cdef class Vocab:
width, you have to call this to change the size of the vectors. width, you have to call this to change the size of the vectors.
""" """
if not isinstance(self.vectors, Vectors): if not isinstance(self.vectors, Vectors):
raise ValueError(Errors.E849.format(action="reset", vectors_type=type(self.vectors))) raise ValueError(Errors.E849.format(method="reset_vectors", vectors_type=type(Vectors)))
if width is not None and shape is not None: if width is not None and shape is not None:
raise ValueError(Errors.E065.format(width=width, shape=shape)) raise ValueError(Errors.E065.format(width=width, shape=shape))
elif shape is not None: elif shape is not None:
@ -311,7 +311,7 @@ cdef class Vocab:
def deduplicate_vectors(self): def deduplicate_vectors(self):
if not isinstance(self.vectors, Vectors): if not isinstance(self.vectors, Vectors):
raise ValueError(Errors.E849.format(action="deduplicate", vectors_type=type(self.vectors))) raise ValueError(Errors.E849.format(method="deduplicate_vectors", vectors_type=type(self.vectors)))
if self.vectors.mode != VectorsMode.default: if self.vectors.mode != VectorsMode.default:
raise ValueError(Errors.E858.format( raise ValueError(Errors.E858.format(
mode=self.vectors.mode, mode=self.vectors.mode,
@ -366,7 +366,7 @@ cdef class Vocab:
DOCS: https://spacy.io/api/vocab#prune_vectors DOCS: https://spacy.io/api/vocab#prune_vectors
""" """
if not isinstance(self.vectors, Vectors): if not isinstance(self.vectors, Vectors):
raise ValueError(Errors.E849.format(action="prune", vectors_type=type(self.vectors))) raise ValueError(Errors.E849.format(method="prune_vectors", vectors_type=type(Vectors)))
if self.vectors.mode != VectorsMode.default: if self.vectors.mode != VectorsMode.default:
raise ValueError(Errors.E858.format( raise ValueError(Errors.E858.format(
mode=self.vectors.mode, mode=self.vectors.mode,