diff --git a/spacy/errors.py b/spacy/errors.py index d143e341c..ab8e69487 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -968,6 +968,7 @@ class Errors(metaclass=ErrorsWithCodes): "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.") + 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 diff --git a/spacy/pipeline/spancat.py b/spacy/pipeline/spancat.py index 2f10a2ff4..3a32b4e7a 100644 --- a/spacy/pipeline/spancat.py +++ b/spacy/pipeline/spancat.py @@ -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 Optimizer from thinc.types import Ragged, Ints2d, Floats2d -from wasabi import msg import numpy @@ -367,12 +366,7 @@ class SpanCategorizer(TrainablePipe): self.scorer = scorer self.add_negative_label = add_negative_label if not allow_overlap and max_positive is not None and max_positive > 1: - self.cfg["allow_overlap"] = True - 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." - ) + raise ValueError(Errors.E1051.format(max_positive=max_positive)) @property def key(self) -> str: