flair icon indicating copy to clipboard operation
flair copied to clipboard

Sentimental Classification for Multiple Sentences

Open KaiyeYang-git opened this issue 1 year ago • 1 comments

I have understood how to classify one sentence's sentiments from '''TextClassifier.load('sentiment-fast')''' However, how can I do multiple sentences for their separate sentiments for having a fast processing speed? I know a for loop is functional for this case it is sooo slow

the example I am doing now is still based on one sentence: scaler = MinMaxScaler(feature_range=(-1, 1)) flair_score=[] def flairSentimentAnalysis(sentiment_text): classifier = TextClassifier.load('sentiment-fast') sentence = Sentence(sentiment_text) classifier.predict(sentence) sentence.labels[0].to_dict() attitude=sentence.labels[0].value score=sentence.labels[0].score if attitude=='NEGATIVE': score=-score return score

for text in raw_data['new_processed_text'][0:10]: score=flairSentimentAnalysis(text) flair_score.append(score) flair_attitude_score=np.array(flair_score).reshape(-1,1) flair_result=scaler.fit_transform(flair_attitude_score).flatten()

KaiyeYang-git avatar Jul 24 '22 10:07 KaiyeYang-git

I have put all my sentences in a list and it can only generate one result which represents the sentiments of all sentence, but not the sentiments of each sentence.

Screenshot 2022-07-25 143850

KaiyeYang-git avatar Jul 25 '22 13:07 KaiyeYang-git

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 23 '22 00:11 stale[bot]