feat: improve search highlighting system#39
Merged
kdroidFilter merged 6 commits intomasterfrom Jan 20, 2026
Merged
Conversation
…sions Add a blacklist mechanism to filter out LLM-generated dictionary mappings that incorrectly link unrelated Hebrew words. The blacklist is loaded from a TSV resource file for easy modification. This is a temporary workaround until the lexical dictionary itself can be corrected.
Keep full dictionary expansions for search to maintain good recall, but filter out hallucinated mappings only when building highlight terms to avoid highlighting unrelated words.
2-letter words should only be highlighted if they were explicitly written in the query, not when they come from dictionary expansion.
Instead of centering the snippet around the first occurrence of any anchor term, find the position where the most query terms cluster together. This ensures the snippet shows the most relevant part of the text when multiple query terms appear scattered throughout.
- Inline findBestAnchorPosition into buildSnippetInternal - Limit to 5 occurrences per term to bound search space - Early exit when all terms found clustered together - Use simpler data structures (Pair instead of data class)
Add public method to build highlight terms with dictionary expansion, filtered for hallucinations and 2-letter terms. This enables find-in-page to highlight the same words as global search.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
buildHighlightTerms()API for intelligent find-in-page modeTechnical Details
hallucination_blacklist.tsvresource file for easy modificationbuildHighlightTerms(query)exposes dictionary expansion for reuseTest plan