mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 09:57:26 +03:00 
			
		
		
		
	raise error instead of just print
This commit is contained in:
		
							parent
							
								
									e847487ebb
								
							
						
					
					
						commit
						6f3b257cf4
					
				| 
						 | 
					@ -968,6 +968,7 @@ class Errors(metaclass=ErrorsWithCodes):
 | 
				
			||||||
             "with `displacy.serve(doc, port=port)`")
 | 
					             "with `displacy.serve(doc, port=port)`")
 | 
				
			||||||
    E1050 = ("Port {port} is already in use. Please specify an available port with `displacy.serve(doc, port=port)` "
 | 
					    E1050 = ("Port {port} is already in use. Please specify an available port with `displacy.serve(doc, port=port)` "
 | 
				
			||||||
             "or use `auto_switch_port=True` to pick an available port automatically.")
 | 
					             "or use `auto_switch_port=True` to pick an available port automatically.")
 | 
				
			||||||
 | 
					    E1051 = ("'allow_overlap' can only be False when max_positive is 1, but found 'max_positive': {max_positive}.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Deprecated model shortcuts, only used in errors and warnings
 | 
					# Deprecated model shortcuts, only used in errors and warnings
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,6 @@ from dataclasses import dataclass
 | 
				
			||||||
from thinc.api import Config, Model, get_current_ops, set_dropout_rate, Ops
 | 
					from thinc.api import Config, Model, get_current_ops, set_dropout_rate, Ops
 | 
				
			||||||
from thinc.api import Optimizer
 | 
					from thinc.api import Optimizer
 | 
				
			||||||
from thinc.types import Ragged, Ints2d, Floats2d
 | 
					from thinc.types import Ragged, Ints2d, Floats2d
 | 
				
			||||||
from wasabi import msg
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import numpy
 | 
					import numpy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -367,12 +366,7 @@ class SpanCategorizer(TrainablePipe):
 | 
				
			||||||
        self.scorer = scorer
 | 
					        self.scorer = scorer
 | 
				
			||||||
        self.add_negative_label = add_negative_label
 | 
					        self.add_negative_label = add_negative_label
 | 
				
			||||||
        if not allow_overlap and max_positive is not None and max_positive > 1:
 | 
					        if not allow_overlap and max_positive is not None and max_positive > 1:
 | 
				
			||||||
            self.cfg["allow_overlap"] = True
 | 
					            raise ValueError(Errors.E1051.format(max_positive=max_positive))
 | 
				
			||||||
            msg.warn(
 | 
					 | 
				
			||||||
                "'allow_overlap' can only be False when max_positive=1, "
 | 
					 | 
				
			||||||
                f"but found 'max_positive': {max_positive} "
 | 
					 | 
				
			||||||
                "SpanCategorizer is automatically configured with allow_overlap=True."
 | 
					 | 
				
			||||||
            )
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def key(self) -> str:
 | 
					    def key(self) -> str:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user