spylls icon indicating copy to clipboard operation
spylls copied to clipboard

Infinite loop when suggesting

Open dandiep opened this issue 3 years ago • 2 comments

It seems that for some words the generator from suggest() never finishes. I am using the French dictionary from Firefox as my datasource. This works:

dictionary = Dictionary.from_zip("./fr.xpi")

print(list(dictionary.suggest('sommes')))

This goes into an infinite loop:

print(list(dictionary.suggest('decouverte')))

Any ideas/suggestions? Spylls version 0.1.7, Python 3.9.7

dandiep avatar Apr 13 '22 18:04 dandiep

@dandiep Sorry for late response (I am in Kharkiv, Ukraine, you know).

You sure it is infinite loop, not just very long suggestion? On my machine with the French dictionary I tried it took almost 8 min, but eventually returned ['découverte', 'recouverte', 'de couverte', 'de-couverte', 'couverte', 'couverture'].

Why it takes so long is a different question which I'll investigate at some point. Quick debug shows that nothing "too weird" happens, just with a French dictionary/alphabet and a long word the amount of hypotheses to check is huge; but I need to compare it with what hunspell does, maybe it optimizes it away somehow (or maybe the Python implementation is just that slow).

zverok avatar Apr 27 '22 07:04 zverok

Is there anyway to make it opt out of some of the more intensive searching so I can guarantee that this will return quickly?

dandiep avatar Jul 13 '23 22:07 dandiep