underway to wordcount
This commit is contained in:
parent
fae306916f
commit
3b677e5713
4 changed files with 24 additions and 18 deletions
|
|
@ -41,15 +41,15 @@ class SentiTooter:
|
|||
output = self.enModel(**encoded_input)
|
||||
scores = output[0][0].detach().numpy()
|
||||
scores = softmax(scores)
|
||||
print(scores)
|
||||
#print(scores)
|
||||
sentimentIndexWithMaxScore = np.argmax(scores)
|
||||
sentimentLabel = self.labels[sentimentIndexWithMaxScore]
|
||||
sentiment = [sentimentLabel, 'twitter-roberta-base-sentiment', max(scores)]
|
||||
print(sentiment)
|
||||
#print(sentiment)
|
||||
return sentiment
|
||||
case _:
|
||||
compound = self.sia.polarity_scores(content)['compound']
|
||||
print(self.sia.polarity_scores(content), 'vaderSentiment')
|
||||
#print(self.sia.polarity_scores(content), 'vaderSentiment')
|
||||
if compound > (1 / 3):
|
||||
return ['positive', 'vaderSentiment']
|
||||
elif compound < (-1 / 3):
|
||||
|
|
@ -58,7 +58,6 @@ class SentiTooter:
|
|||
return ['neutral', 'vaderSentiment']
|
||||
|
||||
|
||||
|
||||
def initModel(self):
|
||||
# PT
|
||||
tokenizer = AutoTokenizer.from_pretrained(self.enModelType)
|
||||
|
|
@ -66,13 +65,3 @@ class SentiTooter:
|
|||
model = AutoModelForSequenceClassification.from_pretrained(self.enModelType)
|
||||
model.save_pretrained(self.enModelType)
|
||||
return model, tokenizer
|
||||
|
||||
# # TF
|
||||
# model = TFAutoModelForSequenceClassification.from_pretrained(MODEL)
|
||||
# model.save_pretrained(MODEL)
|
||||
|
||||
# text = "Good night 😊"
|
||||
# encoded_input = tokenizer(text, return_tensors='tf')
|
||||
# output = model(encoded_input)
|
||||
# scores = output[0][0].numpy()
|
||||
# scores = softmax(scores)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue