diff --git a/QuantumNexusProtocol/src/ai/sentiment_analysis.py b/QuantumNexusProtocol/src/ai/sentiment_analysis.py new file mode 100644 index 000000000..7b251872f --- /dev/null +++ b/QuantumNexusProtocol/src/ai/sentiment_analysis.py @@ -0,0 +1,17 @@ +import pandas as pd +from textblob import TextBlob + +class SentimentAnalyzer: + def __init__(self, data): + self.data = data + + def analyze_sentiment(self): + self.data['sentiment'] = self.data['text'].apply(lambda x: TextBlob(x).sentiment.polarity) + return self.data[['text', 'sentiment']] + +# Example usage +if __name__ == "__main__": + data = pd.DataFrame({'text': ['I love this!', 'This is terrible.', 'I am neutral.']}) + analyzer = SentimentAnalyzer(data) + results = analyzer.analyze_sentiment() + print("Sentiment Analysis Results:\n", results)