From 28c51d4988ad61fe43a285601e9662ae4794dc2b Mon Sep 17 00:00:00 2001 From: Taksh Date: Fri, 17 Apr 2026 17:09:18 +0530 Subject: [PATCH] Fix HyponymDetector mutating module-level BASE_PATTERNS self.patterns = BASE_PATTERNS binds self.patterns to the module-level list. When extended=True, self.patterns.extend(EXTENDED_PATTERNS) mutates BASE_PATTERNS itself, so: - every subsequent HyponymDetector (including extended=False) inherits the extended patterns, and - creating multiple extended detectors duplicates EXTENDED_PATTERNS in BASE_PATTERNS each time. Copy the list so self.patterns is independent of the module-level data. --- scispacy/hyponym_detector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scispacy/hyponym_detector.py b/scispacy/hyponym_detector.py index d0fc27d2..faf5afab 100644 --- a/scispacy/hyponym_detector.py +++ b/scispacy/hyponym_detector.py @@ -38,7 +38,7 @@ def __init__( ): self.nlp = nlp - self.patterns = BASE_PATTERNS + self.patterns = list(BASE_PATTERNS) if extended: self.patterns.extend(EXTENDED_PATTERNS)