bricks icon indicating copy to clipboard operation
bricks copied to clipboard

[MODULE] - Emotionality detection

Open divyanshukatiyar opened this issue 3 years ago • 3 comments

Please describe the module you would like to add to bricks This module takes a string input and tokenizes it using LeXmo package, sums up the number of words for that associate for each emotion, and return a dictionary of the text and emotions weights.

Do you already have an implementation? If so, please share it here. For instance:

import nltk
nltk.download('punkt')
from nltk import word_tokenize
from nltk.stem.snowball import SnowballStemmer
from LeXmo import LeXmo

text = "As Harry went inside the Chamber of Secrets, he discovered the Basilisk's layer. Before him stood Tom Riddle, with his wand. Harry was numb for a second as if he had seen a ghost. Moments later the giant snake attacked Harry but fortunately, Harry dodged and ran into one of the sewer lines while the serpent followed. The Basilisk couldn't be killed with bare hands but only with a worthy weapon. After killing the snake with the Gryffindor sword, Harry killed Tom by forging the Basilisk's tooth through his diary where the spirit of Tom resided."

emo = LeXmo.LeXmo(text)
emo.pop('text', None)
emo = max(emo, key=emo.get)
print(emo)

Additional context This module requires LeXmo package which can be installed using pip install LeXmo if running on the local machine.

divyanshukatiyar avatar Nov 15 '22 15:11 divyanshukatiyar

In the future we might also add somehting like VADER to this as well.

LeonardPuettmann avatar Nov 16 '22 14:11 LeonardPuettmann

I tested the module. I the refinery it cannot detect emotionality (e.g. in "I am so happy", "sad and tired" etc.). In common testing we got following result: "Oh my goodness it was the best evening ever, hype!" has emotion: anticipation Isn't it only anticipation, if it did not happen yet? Or am I wrong? :D

All in all sometimes not om point. Do we want to try and improve it? :)

SvenjaKern avatar Jun 23 '23 12:06 SvenjaKern

@SvenjaKern Good catch! The LeXmo library is not perfect and I doubt it is even maintained. We should implement a model like this for emotionality detection then: https://huggingface.co/j-hartmann/emotion-english-distilroberta-base

LeonardPuettmannKern avatar Jul 27 '23 09:07 LeonardPuettmannKern