fix: skip empty MHC items and add similarity threshold (closes #7, #8)#125
Merged
woodthom2 merged 1 commit intoharmonydata:mainfrom Jan 15, 2026
Conversation
…ydata#7, harmonydata#8) - Skip MHC questions with empty or whitespace-only text when finding matches, ensuring invalid items don't get matched - Add mhc_min_similarity parameter to filter out matches below a threshold (default 0.0 for backward compatibility) - Add unit tests for empty MHC filtering and similarity threshold Signed-off-by: majiayu000 <1835304752@qq.com>
Contributor
|
Thanks @majiayu000 , please give me a couple of weeks to check this over |
woodthom2
approved these changes
Jan 15, 2026
Contributor
|
Thanks so much @majiayu000 ! |
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.
Description
This PR addresses two related issues with MHC (Mental Health Catalogue) matching:
Issue Remove empty items from MHC #7 - Remove empty items from MHC: Empty or whitespace-only MHC questions are now skipped during matching. This prevents invalid items from being matched to user questions.
Issue Don't match to MHC items if similarity is too low #8 - Don't match to MHC items if similarity is too low: Added a new
mhc_min_similarityparameter that allows filtering out matches below a similarity threshold. Default is 0.0 for backward compatibility, but can be set higher (e.g., 0.5) to filter unrelated matches.Changes
matcher.pyto build a mask of valid MHC questions and skip empty/whitespace itemsmhc_min_similarityparameter to bothmatch_instruments_with_functionandmatch_instrumentsTesting
test_empty_mhc_questions_are_skippedtest_whitespace_only_mhc_questions_are_skippedtest_low_similarity_no_matchtest_high_similarity_matchtest_threshold_filters_unrelatedUsage
Fixes #7, #8