mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 01:48:04 +03:00 
			
		
		
		
	Improve error message when reading vectors
This commit is contained in:
		
							parent
							
								
									db50ac524e
								
							
						
					
					
						commit
						0ddb152be0
					
				| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user