mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 16:07:41 +03:00 
			
		
		
		
	Update errors
This commit is contained in:
		
							parent
							
								
									f7e6313b43
								
							
						
					
					
						commit
						e5f47cd82d
					
				|  | @ -239,6 +239,11 @@ class Errors(object): | ||||||
|             "existing extension, set `force=True` on `{obj}.set_extension`.") |             "existing extension, set `force=True` on `{obj}.set_extension`.") | ||||||
|     E091 = ("Invalid extension attribute {name}: expected callable or None, " |     E091 = ("Invalid extension attribute {name}: expected callable or None, " | ||||||
|             "but got: {value}") |             "but got: {value}") | ||||||
|  |     E092 = ("Could not find or assign name for word vectors. Ususally, the " | ||||||
|  |             "name is read from the model's meta.json in vector.name. " | ||||||
|  |             "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}") | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @add_codes | @add_codes | ||||||
|  | @ -252,6 +257,10 @@ class TempErrors(object): | ||||||
|     T006 = ("Currently history width is hard-coded to 0. Received: {value}.") |     T006 = ("Currently history width is hard-coded to 0. Received: {value}.") | ||||||
|     T007 = ("Can't yet set {attr} from Span. Vote for this feature on the " |     T007 = ("Can't yet set {attr} from Span. Vote for this feature on the " | ||||||
|             "issue tracker: http://github.com/explosion/spaCy/issues") |             "issue tracker: http://github.com/explosion/spaCy/issues") | ||||||
|  |     T008 = ("Bad configuration of Tagger. This is probably a bug within " | ||||||
|  |             "spaCy. We changed the name of an internal attribute for loading " | ||||||
|  |             "pre-trained vectors, and the class has been passed the old name " | ||||||
|  |             "(pretrained_dims) but not the new name (pretrained_vectors).") | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class ModelsWarning(UserWarning): | class ModelsWarning(UserWarning): | ||||||
|  |  | ||||||
|  | @ -707,7 +707,7 @@ def _fix_pretrained_vectors_name(nlp): | ||||||
|         vectors_name = '%s_%s.vectors' % (nlp.meta['lang'], nlp.meta['name']) |         vectors_name = '%s_%s.vectors' % (nlp.meta['lang'], nlp.meta['name']) | ||||||
|         nlp.vocab.vectors.name = vectors_name |         nlp.vocab.vectors.name = vectors_name | ||||||
|     else: |     else: | ||||||
|         raise ValueError("Unnamed vectors") |         raise ValueError(Errors.E092) | ||||||
|     for name, proc in nlp.pipeline: |     for name, proc in nlp.pipeline: | ||||||
|         if not hasattr(proc, 'cfg'): |         if not hasattr(proc, 'cfg'): | ||||||
|             continue |             continue | ||||||
|  |  | ||||||
|  | @ -207,7 +207,7 @@ class Pipe(object): | ||||||
|         def load_model(b): |         def load_model(b): | ||||||
|             # TODO: Remove this once we don't have to handle previous models |             # TODO: Remove this once we don't have to handle previous models | ||||||
|             if 'pretrained_dims' in self.cfg and 'pretrained_vectors' not in self.cfg: |             if 'pretrained_dims' in self.cfg and 'pretrained_vectors' not in self.cfg: | ||||||
|                 self.cfg['pretrained_vectors'] = self.vocab.vectors.name  |                 self.cfg['pretrained_vectors'] = self.vocab.vectors.name | ||||||
|             if self.model is True: |             if self.model is True: | ||||||
|                 self.model = self.Model(**self.cfg) |                 self.model = self.Model(**self.cfg) | ||||||
|             self.model.from_bytes(b) |             self.model.from_bytes(b) | ||||||
|  | @ -234,7 +234,7 @@ class Pipe(object): | ||||||
|         def load_model(p): |         def load_model(p): | ||||||
|             # TODO: Remove this once we don't have to handle previous models |             # TODO: Remove this once we don't have to handle previous models | ||||||
|             if 'pretrained_dims' in self.cfg and 'pretrained_vectors' not in self.cfg: |             if 'pretrained_dims' in self.cfg and 'pretrained_vectors' not in self.cfg: | ||||||
|                 self.cfg['pretrained_vectors'] = self.vocab.vectors.name  |                 self.cfg['pretrained_vectors'] = self.vocab.vectors.name | ||||||
|             if self.model is True: |             if self.model is True: | ||||||
|                 self.model = self.Model(**self.cfg) |                 self.model = self.Model(**self.cfg) | ||||||
|             self.model.from_bytes(p.open('rb').read()) |             self.model.from_bytes(p.open('rb').read()) | ||||||
|  | @ -531,12 +531,7 @@ class Tagger(Pipe): | ||||||
|     @classmethod |     @classmethod | ||||||
|     def Model(cls, n_tags, **cfg): |     def Model(cls, n_tags, **cfg): | ||||||
|         if cfg.get('pretrained_dims') and not cfg.get('pretrained_vectors'): |         if cfg.get('pretrained_dims') and not cfg.get('pretrained_vectors'): | ||||||
|             raise ValueError( |             raise ValueError(TempErrors.T008) | ||||||
|                 "Bad configuration of Tagger --- this is probably a bug " |  | ||||||
|                 "within spaCy. We changed the name of an internal attribute " |  | ||||||
|                 "for loading pre-trained vectors, and the class has been " |  | ||||||
|                 "passed the old name (pretrained_dims) but not the new name " |  | ||||||
|                 "(pretrained_vectors)") |  | ||||||
|         return build_tagger_model(n_tags, **cfg) |         return build_tagger_model(n_tags, **cfg) | ||||||
| 
 | 
 | ||||||
|     def add_label(self, label, values=None): |     def add_label(self, label, values=None): | ||||||
|  | @ -584,8 +579,8 @@ class Tagger(Pipe): | ||||||
|         def load_model(b): |         def load_model(b): | ||||||
|             # TODO: Remove this once we don't have to handle previous models |             # TODO: Remove this once we don't have to handle previous models | ||||||
|             if 'pretrained_dims' in self.cfg and 'pretrained_vectors' not in self.cfg: |             if 'pretrained_dims' in self.cfg and 'pretrained_vectors' not in self.cfg: | ||||||
|                 self.cfg['pretrained_vectors'] = self.vocab.vectors.name  |                 self.cfg['pretrained_vectors'] = self.vocab.vectors.name | ||||||
|   | 
 | ||||||
|             if self.model is True: |             if self.model is True: | ||||||
|                 token_vector_width = util.env_opt( |                 token_vector_width = util.env_opt( | ||||||
|                     'token_vector_width', |                     'token_vector_width', | ||||||
|  |  | ||||||
|  | @ -430,10 +430,7 @@ cdef class Doc: | ||||||
|                 if token.ent_iob == 1: |                 if token.ent_iob == 1: | ||||||
|                     if start == -1: |                     if start == -1: | ||||||
|                         seq = ['%s|%s' % (t.text, t.ent_iob_) for t in self[i-5:i+5]] |                         seq = ['%s|%s' % (t.text, t.ent_iob_) for t in self[i-5:i+5]] | ||||||
|                         raise ValueError( |                         raise ValueError(Errors.E093.format(seq=' '.join(seq))) | ||||||
|                             "token.ent_iob values make invalid sequence: " |  | ||||||
|                             "I without B\n" |  | ||||||
|                             "{seq}".format(seq=' '.join(seq))) |  | ||||||
|                 elif token.ent_iob == 2 or token.ent_iob == 0: |                 elif token.ent_iob == 2 or token.ent_iob == 0: | ||||||
|                     if start != -1: |                     if start != -1: | ||||||
|                         output.append(Span(self, start, i, label=label)) |                         output.append(Span(self, start, i, label=label)) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user