From 9df1c33ff79381faf93096539129fa09ce469eb8 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Mon, 19 Aug 2024 14:33:59 +0700 Subject: [PATCH] Create sentiment_predictor.py --- .../predictors/sentiment_predictor.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 blockchain_integration/pi_network/pi-stablecoin/pi-coin-stabilization/predictors/sentiment_predictor.py diff --git a/blockchain_integration/pi_network/pi-stablecoin/pi-coin-stabilization/predictors/sentiment_predictor.py b/blockchain_integration/pi_network/pi-stablecoin/pi-coin-stabilization/predictors/sentiment_predictor.py new file mode 100644 index 000000000..e74757633 --- /dev/null +++ b/blockchain_integration/pi_network/pi-stablecoin/pi-coin-stabilization/predictors/sentiment_predictor.py @@ -0,0 +1,11 @@ +import pandas as pd +from nltk.sentiment import SentimentIntensityAnalyzer + +class SentimentPredictor: + def __init__(self, data): + self.data = data + self.sia = SentimentIntensityAnalyzer() + + def predict(self, input_text): + sentiment = self.sia.polarity_scores(input_text) + return sentiment['compound']