friendship ended with textblob nltk vader is my new best friend
This commit is contained in:
parent
41bad42bbb
commit
8dace1a547
1 changed files with 10 additions and 4 deletions
14
bot.py
14
bot.py
|
@ -6,7 +6,6 @@ import markovify
|
||||||
import nltk
|
import nltk
|
||||||
from nltk.tokenize import word_tokenize
|
from nltk.tokenize import word_tokenize
|
||||||
import random
|
import random
|
||||||
from textblob import TextBlob
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
@ -21,6 +20,9 @@ from better_profanity import profanity
|
||||||
from config import *
|
from config import *
|
||||||
import traceback
|
import traceback
|
||||||
import shutil
|
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
|
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(',')
|
positive_gifs = os.getenv("POSITIVE_GIFS").split(',')
|
||||||
|
|
||||||
def is_positive(sentence):
|
def is_positive(sentence):
|
||||||
blob = TextBlob(sentence)
|
scores = analyzer.polarity_scores(sentence)
|
||||||
sentiment_score = blob.sentiment.polarity
|
sentiment_score = scores['compound']
|
||||||
print(f"{DEBUG}{get_translation(LOCALE, 'sentence_positivity')} {sentiment_score}{RESET}")
|
|
||||||
|
# forcin this fucker
|
||||||
|
debug_message = f"{DEBUG}{get_translation(LOCALE, 'sentence_positivity')} {sentiment_score}{RESET}"
|
||||||
|
print(debug_message)
|
||||||
|
|
||||||
return sentiment_score > 0.1
|
return sentiment_score > 0.1
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue