Skip to content

Fix: Prevent false positives in expertise keyword matching#21

Closed
Atharva-1512 wants to merge 2 commits intoARPAHLS:mainfrom
Atharva-1512:fix-keyword-boundary-matching
Closed

Fix: Prevent false positives in expertise keyword matching#21
Atharva-1512 wants to merge 2 commits intoARPAHLS:mainfrom
Atharva-1512:fix-keyword-boundary-matching

Conversation

@Atharva-1512
Copy link
Copy Markdown
Contributor

Replaced substring matching with regex word boundary matching to avoid incorrect matches (e.g., "law" matching "flaw").

  • Uses re.search with word boundaries
  • Case-insensitive matching
  • Improves expertise scoring accuracy

Fixes #4

@rosspeili
Copy link
Copy Markdown
Contributor

rosspeili commented Mar 21, 2026

Hi @Atharva-1512 ! Thanks so much for taking the time to submit this PR and for looking into Issue #4.

After reviewing the specific changes here, we won't be able to merge this one for a few reasons:

  1. The Issue is already fixed in main: If you check the current codebase (rooms/session.py), the strict \b word boundary logic has actually already been implemented in a previous commit!
    if re.search(rf"\b{re.escape(kw.lower())}\b", context_lower):
  2. Redundant Regex Logic: The proposed change adds re.IGNORECASE to the regex search. However, because the text is specifically lowercased right above it (context_lower = context_text.lower()), the IGNORECASE flag is redundant against the already-lowercased string and won't improve performance.
  3. .gitignore Additions: This PR bundles in a change to .gitignore for .history/. We prefer to keep personal IDE-specific folders (like VS Code's Local History) out of the project's global .gitignore to keep commits focused strictly on the feature or fix at hand.

Because the underlying bug has already been patched in main, I'm going to go ahead and close this PR. But thank you again for being willing to contribute, and feel free to check out our other open issues!

Thanks again. <3

@rosspeili rosspeili assigned rosspeili and Atharva-1512 and unassigned rosspeili Mar 21, 2026
@rosspeili rosspeili closed this Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: strict expertise keyword matching using word boundaries

2 participants