From 8dace1a5479d6b031a769486c5852e7aca3b9192 Mon Sep 17 00:00:00 2001 From: WhatDidYouExpect <89535984+WhatDidYouExpect@users.noreply.github.com> Date: Mon, 24 Mar 2025 21:31:45 +0100 Subject: [PATCH] friendship ended with textblob nltk vader is my new best friend --- bot.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bot.py b/bot.py index f5ab657..fa25e29 100644 --- a/bot.py +++ b/bot.py @@ -6,7 +6,6 @@ import markovify import nltk from nltk.tokenize import word_tokenize import random -from textblob import TextBlob import os import time import re @@ -21,6 +20,9 @@ from better_profanity import profanity from config import * import traceback import shutil +from nltk.sentiment.vader import SentimentIntensityAnalyzer + +analyzer = SentimentIntensityAnalyzer() print(splashtext) # you can use https://patorjk.com/software/taag/ for 3d text or just remove this entirely @@ -362,9 +364,13 @@ def ping_server(): positive_gifs = os.getenv("POSITIVE_GIFS").split(',') def is_positive(sentence): - blob = TextBlob(sentence) - sentiment_score = blob.sentiment.polarity - print(f"{DEBUG}{get_translation(LOCALE, 'sentence_positivity')} {sentiment_score}{RESET}") + scores = analyzer.polarity_scores(sentence) + sentiment_score = scores['compound'] + + # forcin this fucker + debug_message = f"{DEBUG}{get_translation(LOCALE, 'sentence_positivity')} {sentiment_score}{RESET}" + print(debug_message) + return sentiment_score > 0.1