anthropics / anthropics/claude-cookbooks

[PROPOSAL] Cookbook: Aspect-Based Sentiment Analysis with Claude API

未關閉
#697 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Jupyter Notebook
星號
52.7k
分支
6.3k
平均合併
25 分鐘
30 天內合併 PR
6

描述

Preflight Checklist

(1) I have searched existing cookbooks, and this topic isn't already covered
(2) This proposal focuses on the Claude API/SDK capabilities (not external frameworks)
(3) I am prepared to implement this cookbook

Problem
Developers building review analysis systems, customer feedback tools, or
Social media monitors need more than basic positive/negative sentiment.
They need aspect-level insights.
For example, a review like

"The camera takes stunning photos, but the battery dies way too fast. The price is reasonable."

Contains three distinct signals:

camera → positive
battery life → negative
price → neutral

Basic sentiment analysis collapses this into a single ambiguous label.
There is currently no cookbook in this repo demonstrating aspect-based
sentiment analysis (ABSA) with Claude.

Proposed Cookbook
A Jupyter notebook (capabilities/aspect_based_sentiment_analysis/guide.ipynb)
demonstrating ABSA using Claude's tool for structured output.

What it covers:
Defining a tool schema that enforces structured JSON output (aspect, sentiment, confidence, evidence)
Extracting explicit and implicit aspects from review text
Batch processing multiple reviews across domains (smartphones, restaurants, apps, hotels)
Filtering by confidence score for production-ready pipelines
Visualising sentiment distributions with matplotlib

What makes it different from the existing classification cookbook:
The classification cookbook assigns a single category to a whole document.
This cookbook extracts multiple structured entities per document, each
With its own sentiment label, a fundamentally different pattern using a tool.
Target Audience
Developers building:

Product review dashboards (e-commerce, app stores)
Customer feedback analysis systems
Social media brand monitoring tools
Healthcare patient experience platforms

Implementation Plan
I have a working implementation ready:

guide.ipynb: full notebook with tool definition, batch analysis, DataFrame output, visualisation, and a try-it-yourself cell
README.md folder, readme with usage example and model recommendations
Tested with Claude-Haiku-4.5 (fast, cost-efficient for batch use)
Follows repo conventions: non-dated model alias, %%capture for pip installs, markdown/code cell structure

Happy to open a PR immediately upon maintainer approval.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。