From 19a93d24436215c4d8234bc9b76421800b97e666 Mon Sep 17 00:00:00 2001 From: Untone Date: Sun, 29 Sep 2024 13:44:17 +0300 Subject: [PATCH] ocr-stab5 --- handlers/messages_routing.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/handlers/messages_routing.py b/handlers/messages_routing.py index 608d354..1b1ab3c 100644 --- a/handlers/messages_routing.py +++ b/handlers/messages_routing.py @@ -113,14 +113,15 @@ async def messages_routing(msg, state): normalized_text = normalize(text) toxic_score = detector(normalized_text) - toxic_perc = math.floor(toxic_score * 100) - if toxic_score < 0.9 and text != text.replace(' ', ''): + toxic_perc = toxic_score * 100 + logger.info(f'original toxic: {toxic_perc}') + if toxic_score < 0.91: 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) - await redis.set(f"toxic:{cid}:{uid}:{mid}", toxic_perc, ex=60 * 60 * 24 * 3) + await redis.set(f"toxic:{cid}:{uid}:{mid}", math.floor(toxic_perc), ex=60 * 60 * 24 * 3) if toxic_score > 0.75: if toxic_score > 0.90: await redis.set(f"removed:{uid}:{cid}:{mid}", text)