Closed NightMachinery closed 7 months ago
BTW, this application would benefit from being able to sort the results so that "better" matches are on top. I don't think ugrep
can expose such a score?
int left_score = static_cast<int>(rapidfuzz::fuzz::partial_ratio(filterString.toStdWString(), leftData.toStdWString()));
int right_score = static_cast<int>(rapidfuzz::fuzz::partial_ratio(filterString.toStdWString(), rightData.toStdWString()));
return left_score > right_score;
Please take a look at this project: FuzzyMatcher. The fuzzy matcher is also included with RE/flex which in turn is included in ugrep. For case-independent matching and Unicode support, you want to use the regex converter and pass the converted regex string to the fuzzy matcher for matching. There are examples that show how to do that and use (?i)PATTERN
to make PATTERN
match case insensitive. The fuzzy matcher has an edits()
method that returns the edit distance of a match, after matching.
@genivia-inc Do these libraries support --bool
syntax?
@genivia-inc Do these libraries support
--bool
syntax?
No. The --bool
syntax is layered on top, using CNF normalization in ugrep/src/cnf.cpp
and by using multiple matchers, one for each term in the CNF. E.g. a|(b c)
is normalized to (a|b) (a|c)
for which two (fuzzy)matchers are created for patterns a|b
and a|c
. Both patterns must match (on the same line or anywhere in a file with --files
).
I like to add
ugrep
as an option for "fuzzy" finding to https://github.com/ahrm/sioyek/issues/567 . The code currently does this:where
s1
is the pattern ands2
is the string that I want to check for a match. I like to do this match usingugrep --bool --smart-case
. Can I do this without calling a subprocess?PS: Complete code snippet: