1
$\begingroup$

I have thousands of sentences that I would need to label based on their sentiment. An example is

Testo
"Può dirmi quale fotocamera della Sony fa delle belle foto?"
"Che macchina fantastica! Ha smesso di funzionare dopo due giorni"
"Quel pallavolista ha un fisico pauroso"
"Questo iPad è fantastico"

I have tried using Fasttext (Python Package) but I do not know how to add the sentiment label in a new column. Also, I got the wrong sentiment (below it is shown the expected output).

Testo                                                            Sentiment
"Può dirmi quale fotocamera della Sony fa delle belle foto?"         0
"Che macchina fantastica! Ha smesso di funzionare dopo due giorni"  -1
"Quel pallavolista ha un fisico pauroso"                             1
"Questo iPad è fantastico"                                           1

How can I do it?

$\endgroup$
1
  • $\begingroup$ Do you already have a trained model to classify sentiment? $\endgroup$
    – Leevo
    Jun 4 '20 at 15:40
1
$\begingroup$

Do you have a working method to get the sentiment label for an individual sentence?

If so, I would think you could just create a method to get the sentiment given a sentence and use it's return value as the row entry.

The apply function from pandas will apply a function to every row if you specify axis=1

def getSentiment(row):
    # Do some sentiment operations here on row['Testo']
    return sentiment_label

df.apply(getSentiment, axis=1)
$\endgroup$
2
  • $\begingroup$ thank you @Sean Payne. May I ask you if you suggest to get the sentiment building some rules from scratch or just using some already existing tool in python (what you should suggest)? $\endgroup$
    – LdM
    Jun 4 '20 at 23:15
  • 1
    $\begingroup$ I'm not as sure about the sentiment labeling. I'm guessing there has been a ton done in that field though as the Twitter sentiment labeling is a popular beginner exercise, so consider doing some more Google searching to look for an existing method. $\endgroup$
    – Sean Payne
    Jun 5 '20 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.