diff --git a/spacy/pipeline/span_finder.py b/spacy/pipeline/span_finder.py index 988dd4ce9..1a32fe12e 100644 --- a/spacy/pipeline/span_finder.py +++ b/spacy/pipeline/span_finder.py @@ -148,6 +148,11 @@ def span_finder_score( return scores +class _MaxInt(int): + def __le__(self, other): + return False + + class SpanFinder(TrainablePipe): """Pipeline that learns span boundaries""" @@ -184,15 +189,16 @@ class SpanFinder(TrainablePipe): self.vocab = nlp.vocab self.threshold = threshold if max_length is None: - max_length = float("inf") + max_length = _MaxInt() if min_length is None: min_length = 1 + + self.min_length = min_length + self.max_length = max_length if max_length < 1 or min_length < 1: raise ValueError( Errors.E1052.format(min_length=min_length, max_length=max_length) ) - self.max_length = max_length - self.min_length = min_length self.predicted_key = predicted_key self.training_key = training_key self.model = model