sentiment-analyzer by dkyazzentwatwa/chatgpt-skills
npx skills add https://github.com/dkyazzentwatwa/chatgpt-skills --skill sentiment-analyzer通过详细的评分、情绪检测和可视化功能分析文本内容的情感。可处理单个文本、CSV 文件或跟踪情感随时间变化的趋势。
from scripts.sentiment_analyzer import SentimentAnalyzer
# 分析单个文本
analyzer = SentimentAnalyzer()
result = analyzer.analyze("I love this product! It's amazing.")
print(f"Sentiment: {result['sentiment']} ({result['score']:.2f})")
# 批量分析 CSV
results = analyzer.analyze_csv("reviews.csv", text_column="review")
analyzer.plot_distribution("sentiment_dist.png")
analyzer = SentimentAnalyzer()
result = analyzer.analyze("This is great!")
# 返回:
# {
# 'text': 'This is great!',
# 'sentiment': 'positive', # positive, negative, neutral
# 'score': 0.85, # -1.0 to 1.0
# 'confidence': 0.92, # 0.0 to 1.0
# 'subjectivity': 0.75, # 0.0 (objective) to 1.0 (subjective)
# 'emotions': {'joy': 0.8, 'anger': 0.0, ...}
# }
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 从列表分析
texts = ["Great product!", "Terrible service.", "It's okay."]
results = analyzer.analyze_batch(texts)
# 从 CSV 分析
results = analyzer.analyze_csv(
"reviews.csv",
text_column="review_text",
output="results.csv"
)
# 分析随时间变化的情感
results = analyzer.analyze_csv(
"posts.csv",
text_column="content",
date_column="posted_at"
)
analyzer.plot_trend("sentiment_trend.png")
# 情感分布
analyzer.plot_distribution("distribution.png")
# 情感随时间变化
analyzer.plot_trend("trend.png")
# 按情感分类的词云
analyzer.plot_wordcloud("positive", "positive_words.png")
# 分析单个文本
python sentiment_analyzer.py --text "I love this product!"
# 分析文件
python sentiment_analyzer.py --input reviews.csv --column review --output results.csv
# 带可视化
python sentiment_analyzer.py --input reviews.csv --column text --plot distribution.png
# 趋势分析
python sentiment_analyzer.py --input posts.csv --column content --date posted_at --trend trend.png
| 参数 | 描述 | 默认值 |
|---|---|---|
--text | 要分析的单个文本 | - |
--input | 输入的 CSV 文件 | - |
--column | 文本列名 | text |
--date | 用于趋势分析的日期列 | - |
--output | 输出的 CSV 文件 | - |
--plot | 保存分布图 | - |
--trend | 保存趋势图 | - |
--format | 输出格式 (json, csv) | json |
analyzer = SentimentAnalyzer()
results = analyzer.analyze_csv("amazon_reviews.csv", text_column="review")
# 汇总统计
positive = sum(1 for r in results if r['sentiment'] == 'positive')
negative = sum(1 for r in results if r['sentiment'] == 'negative')
print(f"Positive: {positive}, Negative: {negative}")
# 平均情感得分
avg_score = sum(r['score'] for r in results) / len(results)
print(f"Average sentiment: {avg_score:.2f}")
analyzer = SentimentAnalyzer()
# 分析带时间戳的推文
results = analyzer.analyze_csv(
"tweets.csv",
text_column="tweet_text",
date_column="created_at"
)
# 绘制情感趋势图
analyzer.plot_trend("twitter_sentiment.png", title="Brand Sentiment Over Time")
analyzer = SentimentAnalyzer()
feedback = [
"Your support team was incredibly helpful!",
"The product broke after one day.",
"Shipping was on time.",
"I'm extremely disappointed with the quality.",
"It works as expected, nothing special."
]
for text in feedback:
result = analyzer.analyze(text)
print(f"{result['sentiment'].upper():8} ({result['score']:+.2f}): {text[:50]}")
{
"text": "I love this product!",
"sentiment": "positive",
"score": 0.85,
"confidence": 0.92,
"subjectivity": 0.75,
"emotions": {
"joy": 0.82,
"anger": 0.02,
"sadness": 0.01,
"fear": 0.03,
"surprise": 0.12
}
}
| text | sentiment | score | confidence | subjectivity |
|---|---|---|---|---|
| Great product! | positive | 0.85 | 0.91 | 0.80 |
| Terrible... | negative | -0.72 | 0.88 | 0.65 |
textblob>=0.17.0
pandas>=2.0.0
matplotlib>=3.7.0
每周安装量
82
代码仓库
GitHub 星标数
39
首次出现
2026 年 1 月 24 日
安全审计
安装于
opencode70
gemini-cli66
codex66
cursor65
github-copilot63
amp57
Analyze the sentiment of text content with detailed scoring, emotion detection, and visualization capabilities. Process single texts, CSV files, or track sentiment trends over time.
from scripts.sentiment_analyzer import SentimentAnalyzer
# Analyze single text
analyzer = SentimentAnalyzer()
result = analyzer.analyze("I love this product! It's amazing.")
print(f"Sentiment: {result['sentiment']} ({result['score']:.2f})")
# Batch analyze CSV
results = analyzer.analyze_csv("reviews.csv", text_column="review")
analyzer.plot_distribution("sentiment_dist.png")
analyzer = SentimentAnalyzer()
result = analyzer.analyze("This is great!")
# Returns:
# {
# 'text': 'This is great!',
# 'sentiment': 'positive', # positive, negative, neutral
# 'score': 0.85, # -1.0 to 1.0
# 'confidence': 0.92, # 0.0 to 1.0
# 'subjectivity': 0.75, # 0.0 (objective) to 1.0 (subjective)
# 'emotions': {'joy': 0.8, 'anger': 0.0, ...}
# }
# From list
texts = ["Great product!", "Terrible service.", "It's okay."]
results = analyzer.analyze_batch(texts)
# From CSV
results = analyzer.analyze_csv(
"reviews.csv",
text_column="review_text",
output="results.csv"
)
# Analyze sentiment over time
results = analyzer.analyze_csv(
"posts.csv",
text_column="content",
date_column="posted_at"
)
analyzer.plot_trend("sentiment_trend.png")
# Sentiment distribution
analyzer.plot_distribution("distribution.png")
# Sentiment over time
analyzer.plot_trend("trend.png")
# Word cloud by sentiment
analyzer.plot_wordcloud("positive", "positive_words.png")
# Analyze single text
python sentiment_analyzer.py --text "I love this product!"
# Analyze file
python sentiment_analyzer.py --input reviews.csv --column review --output results.csv
# With visualization
python sentiment_analyzer.py --input reviews.csv --column text --plot distribution.png
# Trend analysis
python sentiment_analyzer.py --input posts.csv --column content --date posted_at --trend trend.png
| Argument | Description | Default |
|---|---|---|
--text | Single text to analyze | - |
--input | Input CSV file | - |
--column | Text column name | text |
--date | Date column for trends | - |
--output |
analyzer = SentimentAnalyzer()
results = analyzer.analyze_csv("amazon_reviews.csv", text_column="review")
# Summary statistics
positive = sum(1 for r in results if r['sentiment'] == 'positive')
negative = sum(1 for r in results if r['sentiment'] == 'negative')
print(f"Positive: {positive}, Negative: {negative}")
# Average sentiment score
avg_score = sum(r['score'] for r in results) / len(results)
print(f"Average sentiment: {avg_score:.2f}")
analyzer = SentimentAnalyzer()
# Analyze tweets with timestamps
results = analyzer.analyze_csv(
"tweets.csv",
text_column="tweet_text",
date_column="created_at"
)
# Plot sentiment trend
analyzer.plot_trend("twitter_sentiment.png", title="Brand Sentiment Over Time")
analyzer = SentimentAnalyzer()
feedback = [
"Your support team was incredibly helpful!",
"The product broke after one day.",
"Shipping was on time.",
"I'm extremely disappointed with the quality.",
"It works as expected, nothing special."
]
for text in feedback:
result = analyzer.analyze(text)
print(f"{result['sentiment'].upper():8} ({result['score']:+.2f}): {text[:50]}")
{
"text": "I love this product!",
"sentiment": "positive",
"score": 0.85,
"confidence": 0.92,
"subjectivity": 0.75,
"emotions": {
"joy": 0.82,
"anger": 0.02,
"sadness": 0.01,
"fear": 0.03,
"surprise": 0.12
}
}
| text | sentiment | score | confidence | subjectivity |
|---|---|---|---|---|
| Great product! | positive | 0.85 | 0.91 | 0.80 |
| Terrible... | negative | -0.72 | 0.88 | 0.65 |
textblob>=0.17.0
pandas>=2.0.0
matplotlib>=3.7.0
Weekly Installs
82
Repository
GitHub Stars
39
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode70
gemini-cli66
codex66
cursor65
github-copilot63
amp57
DOCX文件创建、编辑与分析完整指南 - 使用docx-js、Pandoc和Python脚本
50,600 周安装
AI图像生成与编辑Skill:使用FAL.AI API生成和编辑高质量图像
81 周安装
测试质量分析指南:检测异味、提升覆盖率与测试最佳实践
81 周安装
规范驱动开发 (Spec-Driven Development) | 自适应项目规划与执行 | Tech Lead's Club
81 周安装
PPTX文档自动化技能:使用Python和Node.js编程创建编辑PowerPoint演示文稿
81 周安装
project-discover:AI辅助项目逆向工程与知识沉淀工具,一键建立项目SSOT
81 周安装
Angular 17+ 现代开发规范:独立组件、Signal 状态管理与原生控制流最佳实践
81 周安装
| Output CSV file |
| - |
--plot | Save distribution plot | - |
--trend | Save trend plot | - |
--format | Output format (json, csv) | json |