stopwords-fix

This commit is contained in:
2024-09-29 13:08:39 +03:00
parent 3e4aefc429
commit 5f3bbe6229
2 changed files with 20 additions and 13 deletions

View File

@@ -115,12 +115,8 @@ async def messages_routing(msg, state):
toxic_score = detector(normalized_text)
toxic_perc = math.floor(toxic_score * 100)
if toxic_score < 0.9 and text != text.replace(' ', ''):
logger.info('check without spaces')
if check_stopwords(normalized_text):
logger.info('stopword detected without spaces, toxicity +40%')
toxic_perc += 40
else:
logger.info('ok')
logger.info('re-check without spaces')
toxic_perc += check_stopwords(normalized_text):
logger.info(f"text: {normalized_text}\ntoxic: {toxic_perc}%")
await redis.set(f"toxic:{cid}", mid)