Skip to content
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

BESTMATCH ignoring user-specified costs #470

Open
M0rtenB opened this issue May 13, 2022 · 0 comments
Open

BESTMATCH ignoring user-specified costs #470

M0rtenB opened this issue May 13, 2022 · 0 comments

Comments

@M0rtenB
Copy link

M0rtenB commented May 13, 2022

It seems that even when BESTMATCH is specified, the fuzzy matching engine doesn't account for user-specified costs in choosing the optimal match. Consider the following examples:

In [1]: regex.search(r'(voices){1i+1d+2s<=2}', 'voixes voicees', regex.BESTMATCH)
Out[1]: <regex.Match object; span=(0, 6), match='voixes', fuzzy_counts=(1, 0, 0)>

In [2]: regex.search(r'(voices){1i+1d+2s<=1}', 'voixes voicees', regex.BESTMATCH)
Out[2]: <regex.Match object; span=(7, 14), match='voicees', fuzzy_counts=(0, 1, 0)>

Even if the cost is allowed to exceed 1, as in the first search, the engine should still match "voicees", as an insertion of an extra "e" is less of a cost than replacing "c" with "x".

A natural extension would be to allow regex.search(r'(voices){1i+1d+2s}', 'voixes voicees', regex.BESTMATCH), i.e. find the best match with no limit, using costs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant