fix: use pre-wrapped candidate patterns after #932 refactor

This commit is contained in:
mvalentsev
2026-04-16 10:37:18 +05:00
parent 8bf940f861
commit 973bd62a9a
+4 -2
View File
@@ -147,10 +147,12 @@ def _candidate_entity_words(text: str) -> list:
from .i18n import get_entity_patterns
patterns = get_entity_patterns(MempalaceConfig().entity_languages)
# candidate_patterns are pre-wrapped with boundary + capture group
# by get_entity_patterns (#932), compile directly without re-wrapping.
rxs = []
for raw_pat in patterns["candidate_patterns"]:
for pat in patterns["candidate_patterns"]:
try:
rxs.append(re.compile(rf"\b({raw_pat})\b"))
rxs.append(re.compile(pat))
except re.error:
continue
_CANDIDATE_RX_CACHE = rxs