Twitter-keyword-analysis / sen_model.py
EmanuelRiquelme's picture
Upload 5 files
3efdb8d
raw
history blame contribute delete
368 Bytes
from transformers import pipeline
import numpy as np
specific_model = pipeline(model="finiteautomata/bertweet-base-sentiment-analysis")
def Sentiment(tweets):
output_model = specific_model(tweets.tolist())
labels = ["NEG","NEU","POS"]
idx = []
for output in output_model:
idx.append(labels.index(output["label"])-1)
return np.array(idx)