limit the number of variants that can be produced

This commit is contained in:
Sarah Hoffmann
2021-07-02 16:42:13 +02:00
parent c32551b4e0
commit 62d5984b1b
2 changed files with 7 additions and 0 deletions

View File

@@ -105,6 +105,11 @@ class ICUNameProcessor:
partials = [v + done + r
for v, r in itertools.product(partials, repl)
if not force_space or r.startswith(' ')]
if len(partials) > 128:
# If too many variants are produced, they are unlikely
# to be helpful. Only use the original term.
startpos = 0
break
startpos = pos + len(full)
if full[-1] == ' ':
startpos -= 1