# 导入vaderSentiment情感分析库
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

# 定义情感分析函数
def analyze_sentiment(text):
    analyzer = SentimentIntensityAnalyzer()
    sentiment_score = analyzer.polarity_scores(text)
    return sentiment_score

# 直接在文件里写测试代码，不用导入包
if __name__ == "__main__":
    # 测试1：开心的话
    test_text1 = "我今天学习Python很顺利，超有成就感！"
    result1 = analyze_sentiment(test_text1)
    print(f"文本1：{test_text1}")
    print(f"分析结果1：{result1}\n")
    
    # 测试2：不开心的话
    test_text2 = "今天丢了东西，心情特别差！"
    result2 = analyze_sentiment(test_text2)
    print(f"文本2：{test_text2}")
    print(f"分析结果2：{result2}")