I'm using Emoroberta for emotion detection and I want the output to be all emotions, each with its assigned score and not only the final emotion and its score. How can I do that? This is the code I'm using:
tokenizer = RobertaTokenizerFast.from_pretrained("arpanghoshal/EmoRoBERTa")
model = TFRobertaForSequenceClassification.from_pretrained("arpanghoshal/EmoRoBERTa")
emotion = pipeline('sentiment-analysis', model='arpanghoshal/EmoRoBERTa')
def get_emotion_label(text):
return(emotion(text)[0]['label'])
df['Text']= df['Text'].apply(remove_html).apply(remove_URL).apply(remove_stopwords)
df['Emotion']= df['Text'].apply(get_emotion_label)
So the solution is to add a parameter in the pipeline for it to become:
emotion = pipeline('sentiment-analysis', model='arpanghoshal/EmoRoBERTa' , return_all_scores= True)