fix: skip fuzzy matching for short words (<=4 chars) to prevent false positives like 'lofi' matching 'loli'
This commit is contained in:
parent
204b7fab81
commit
e278f94273
@ -67,12 +67,12 @@ def _is_banned(query: str) -> bool:
|
|||||||
# Fuzzy match check for words in the query
|
# Fuzzy match check for words in the query
|
||||||
query_words = query_lower.split()
|
query_words = query_lower.split()
|
||||||
for word in query_words:
|
for word in query_words:
|
||||||
# Skip very short words (3 chars or less)
|
# Skip short words (4 chars or less) to avoid false positives (e.g. "lofi" matching "loli")
|
||||||
if len(word) <= 3:
|
if len(word) <= 4:
|
||||||
continue
|
continue
|
||||||
for term in _banned_terms:
|
for term in _banned_terms:
|
||||||
# Skip fuzzy matching for very short banned terms (too many false positives)
|
# Skip fuzzy matching for short banned terms (too many false positives)
|
||||||
if len(term) <= 3:
|
if len(term) <= 4:
|
||||||
continue
|
continue
|
||||||
# Only fuzzy match for terms with similar length
|
# Only fuzzy match for terms with similar length
|
||||||
if abs(len(word) - len(term)) > 2:
|
if abs(len(word) - len(term)) > 2:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user