Repository navigation
SearchableListBox: match items containing the query before fuzzy matching - #272
Conversation
…hing The default scorer used only the BHoM WeightedRatio fuzzy match, which scales scores down for long items, so long names and short queries were hidden. Items containing every word of the query now match first; fuzzy matching is a typo fallback for queries of 4+ characters. The fuzzy-only scorer is kept as fuzzy_scorer. Closes #270 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Hello! So the approach (contains-every-word first, fuzzy as a typo fallback) is simple and works. A few small points:
Punctuation-only queries empty the list. Typing . (the first keystroke of .epw) gives no words, so every item is hidden. Could default_scorer show everything when the query has no alphanumeric characters?
Query words can overlap in the item. 8.5 matches RCP85 and a b matches ab, because each word is checked on its own. Fine for a filter if that's intended, just flagging it.
Nit: the test docstring still says "best first", and the test name ..._fuzzy_matching now mostly covers the contains path.
Ran the tests locally (Py 3.13 and 3.10): all 5 in test_bhom_tkinter_ui.py pass. test_colour_scale_builder.py errors with a Tk init.tcl error when run after the UI tests, but it does the same on develop, so it's not from this PR. Probably worth its own issue.
|
@BHoMBot check ready-to-merge |
|
@Felix-Mallinder to confirm, the following actions are now queued:
There are 399 requests in the queue ahead of you. |
Issues addressed by this PR
Closes #270
SearchableListBox'sdefault_scorerused only the BHoM WeightedRatio fuzzy match. WeightedRatio scales scores down when the item is much longer than the query, so long names (e.g.GBR_London.Gatwick_2050_ASHRAE_RCP8.5.epwfor.epw) and short queries (a,lo,205) fell belowmin_scoreand were hidden.min_score.fuzzy_scorer.Test files
Python_Engine/Python/tests/test_bhom_tkinter_ui.py::test_searchable_list_box_fuzzy_matching(new asserts for long items and short queries). All 5 tests in the file pass.Changelog
SearchableListBoxfilter now shows every item containing the typed words, with fuzzy matching as a fallback for typos.Additional comments
🤖 Generated with Claude Code