VADER(Valence Aware Dictionary and sEntiment Reasoner)是专为社交媒体文本设计的情感分析工具,支持Python语言。它通过预训练的词典和规则引擎,快速判断文本情感倾向(正面/负面/中性)。
🛠️ 快速上手步骤
- 安装依赖
pip install nltk
- 下载VADER词典
import nltk nltk.download('vader_lexicon')
- 导入并使用
from nltk.sentiment import SentimentIntensityAnalyzer sia = SentimentIntensityAnalyzer() print(sia.polarity_scores("我最喜欢这个项目!"))
📈 示例输出解析
情感得分类型 | 说明 |
---|---|
neg |
负面情感概率 |
neu |
中性情感概率 |
pos |
正面情感概率 |
compound |
综合情感得分(-1到1) |
🌐 应用场景
- 社交媒体评论分析
- 产品评价情感挖掘
- 即时聊天机器人反馈