1- from models import pos_neg_neu_model , strongest_emotion_model , all_emotion_model , zero_shot_classifier , vader
1+ from models import pos_neg_neu_model , strongest_emotion_model , all_emotion_model , zero_shot_classifier , vader , custom_model
22from pymongo .mongo_client import MongoClient
33# from googleapiclient import discovery
44from dotenv import load_dotenv
@@ -46,6 +46,9 @@ def check_message(message, guild_id, mongo_client):
4646
4747 big_emotions = []
4848
49+ custom_model_sent = custom_model (message )[0 ]["label" ]
50+ custom_model_score = custom_model (message )[0 ]["score" ]
51+
4952 # toxicity_response = google_api_client.comments().analyze(body=analyze_request).execute()
5053 # toxicity_response = float(json.dumps(toxicity_response["attributeScores"]["TOXICITY"]["summaryScore"]["value"], indent=2))
5154 if lexicon :
@@ -73,6 +76,8 @@ def check_message(message, guild_id, mongo_client):
7376 else :
7477 if vader_response < - 0.4 :
7578 return (True , "Very negative" )
79+ if custom_model_sent == "LABEL_0" and custom_model_score > 0.8 :
80+ return (True , "Message is very negative" )
7681 return (False , "Not negative, does not contain an unwanted emotion" )
7782 else :
7883 if (biggest_emotion in unwanted_emotions ) and (not ((sent_label == "NEU" and sent_score > 0.60 ) or (sent_label == "POS" and sent_score > 0.60 ))):
@@ -91,7 +96,7 @@ def check_message(message, guild_id, mongo_client):
9196 if (zero_shot_labels ["scores" ][zero_shot_labels ["labels" ].index (label )] > 0.8 ):
9297 return (True , f"Message contains custom label { label } " )
9398
94- return (False , "Not negative, does not contain unwanted emotion, low toxicity score , and does not contain custom filters" )
99+ return (False , "Not negative, does not contain unwanted emotions , and does not contain custom filters" )
95100
96101if __name__ == "__main__" :
97102 # neg_bad = False
0 commit comments