mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-30 23:47:31 +03:00 
			
		
		
		
	Merge pull request #6187 from svlandeg/fix/begin_training_pipe
This commit is contained in:
		
						commit
						cc08c88a89
					
				|  | @ -85,6 +85,8 @@ class Warnings: | |||
|             "attribute or operator.") | ||||
| 
 | ||||
|     # TODO: fix numbering after merging develop into master | ||||
|     W088 = ("This component implements a 'begin_training' method, " | ||||
|             "which should probably be renamed to 'initialize'.") | ||||
|     W089 = ("The nlp.begin_training method has been renamed to nlp.initialize.") | ||||
|     W090 = ("Could not locate any {format} files in path '{path}'.") | ||||
|     W091 = ("Could not clean/remove the temp directory at {dir}: {msg}.") | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| # cython: infer_types=True, profile=True | ||||
| import warnings | ||||
| from typing import Optional, Tuple | ||||
| import srsly | ||||
| from thinc.api import set_dropout_rate, Model | ||||
|  | @ -6,7 +7,7 @@ from thinc.api import set_dropout_rate, Model | |||
| from ..tokens.doc cimport Doc | ||||
| 
 | ||||
| from ..training import validate_examples | ||||
| from ..errors import Errors | ||||
| from ..errors import Errors, Warnings | ||||
| from .. import util | ||||
| 
 | ||||
| 
 | ||||
|  | @ -33,6 +34,13 @@ cdef class Pipe: | |||
|         self.name = name | ||||
|         self.cfg = dict(cfg) | ||||
| 
 | ||||
|     @classmethod | ||||
|     def __init_subclass__(cls, **kwargs): | ||||
|         """Raise a warning if an inheriting class implements 'begin_training' | ||||
|          (from v2) instead of the new 'initialize' method (from v3)""" | ||||
|         if hasattr(cls, "begin_training"): | ||||
|             warnings.warn(Warnings.W088) | ||||
| 
 | ||||
|     @property | ||||
|     def labels(self) -> Optional[Tuple[str]]: | ||||
|         return [] | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user