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

term frequency and multi highlighting #19

Open
leeoniya opened this issue Jan 25, 2023 · 4 comments
Open

term frequency and multi highlighting #19

leeoniya opened this issue Jan 25, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@leeoniya
Copy link
Owner

this might be more in the realm of a document search, but could be interesting to explore.

in info() or search() use a sticky regex to walk each matched haystack item with an altenation group, track frequency and have that somehow feed into sort(). also compute all highlight ranges.

also can establish some convention for haystack item parts, like heading|summary|content|footer, and ranges can be relative to partition points.

not sure how far this is worth taking. scope creep is a thing to keep in check.

@leeoniya leeoniya added the enhancement New feature or request label Jan 25, 2023
@leeoniya
Copy link
Owner Author

matchAll could be useful for multiple out-of-order stuff, instead of sticky regex

image

@afonso-tsx
Copy link

afonso-tsx commented Jun 22, 2023

is it already possible to have multi match highlighting using this internal interOr flag? @leeoniya

I tried to use it and resulted in a crash with use of .toLowerCase on undefined

@afonso-tsx
Copy link

@leeoniya Any update on this? What work is left to be done in order to have multi match highlighting?

@leeoniya
Copy link
Owner Author

leeoniya commented Jul 29, 2023

the internals rely on 1:1 mapping between needle terms and matched parts in the haystack items, and this is unlikely to change.

probably the best i can do is to expose the internal u.prepQuery() function and leave it up to the user to use interOR flag and run the resulting regexp via .matchAll to find all terms as they appear in any order in the located matches. this could potentially find quite unexpected portions of the matches that dont correspond to the actual ranking logic.

in terms of integrating with uFuzzy.highlight(), it should be sufficient to replace the info.ranges array with the results found using matchAll and use that highlight util function normally.

https://github.com/leeoniya/uFuzzy/blob/9486cf58cd937bc15082de217febfbf793bd589a/src/uFuzzy.js#L216C21-L216C21

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

No branches or pull requests

2 participants