mrabarnett/mrab-regex

Feature request: user specified cost function for fuzzy search with BESTMATCH

Closed this issue · 2 comments

I'm working on an application where mrab-regex is used with a search_expression which looks like this (python fstring): f"(?b)({expected}){{e<={n}}}". I would like to keep the constraint e = s + i + d < n but add the cost function s + 2i + 2d. In other words, performs the optimization:

Find the match, if it exists, of expected which minimize s + 2i + 2d subject to s + i + d < n.

From my understanding of the documentation, there is no way to specify a cost function when using the fuzzy search with BESTMATCH. The cost function s + i + d is used implicitly. Would you say adding this feature would be an improvement to mrab-regex or is it out of scope?

I'm aware my use case is quite simple and might be better served by a more specific implementation, but I'm asking the question in general. While searching for similar issues, I read some touching the subject.

Related issues:

#470
#466
#351

I think I've taken this codebase as far as I can. It really needs a major reworking. If it's not a major bug, I prefer to leave it as-is.

Thanks for your quick response. It's definitely not a bug, but an understandable limitation. This package is already solving multiple other problems and I can imagine how juggling with all of them must already be tricky. For the app I'm working on, I will investigate other solutions more tailored to my limited use case if need be (I was reviewing todos).