-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callable
missing type argument, making some methods partially-Unknown
#60
Comments
I somewhat improved the type hint in https://github.com/rapidfuzz/Levenshtein/blob/main/src/Levenshtein/__init__.pyi to processor: Callable[..., Sequence[Hashable]] | None = None, The problem with def func(a: str) -> str:
return a
Levenshtein.ratio("test", "test2", processor=func) The requirement would be that |
@maxbachmann d64d503 (and follow-up fixes) should close this issue :) |
btw your implementation in Toufool/AutoSplit#272 could be made significantly faster if you have to compare larger amounts of texts: # Levenshtein is just a wrapper for rapidfuzz at this point and rapidfuzz provides quite a few more features + is MIT instead of GPL licensed
from rapidfuzz import process
# Levenshtein.ratio is a normalized Indel similarity (levenshtein with subsitution weight 2).
# Was this intended? Otherwise you should use Levenshtein
from rapidfuzz.distance import Indel
process.extractOne(image_string, texts, scorer=Indel.normalized_similarity) If you only have a few texts, this doesn't really matter though |
Unfortunately that area of code is heavily bottleneck by optical text recognition, at around 1 cycle every 0.25s in the best conditions so far. But I'll definitely take a look at, and consider using directly, rapidfuzz. Especially if I'm just given the code like that ^^ |
Yes then it probably will not make much of a difference. It's going to be a lot faster than that anyway. |
I published |
For example
If it can truly be "anything", you can use
Callable[..., Any]
, but I assume it's meant to beCallable[[Sequence[Hashable]], Sequence[Hashable]]
While at it,
Callable
,Hashable
andSequence
should all be imported fromcollections.abc
.List
andTuple
also don't need to be imported from typing in a type stub, the stdlib names (list
andtuple
) can be used directly.Union
andOptional
can use PEP 604 syntaxThe text was updated successfully, but these errors were encountered: