
点击查看大图

点击查看大图
全面介绍
✨ Emotion Tone Analyzer:让JavaScript更有温度的AI情感引擎 ✨
有没有想过,您的应用也能读懂用户的心情?「Emotion Tone Analyzer」正是为此而生!这款基于尖端AI技术的情感分析工具,让您的JavaScript应用瞬间拥有强大的情感洞察力,为用户带来更个性化、更贴心的体验。
💡 产品简介:AI赋能,智能感知
「Emotion Tone Analyzer」利用先进的AI技术,深入剖析文本的细微情感。它能精准识别快乐、悲伤、愤怒、恐惧、惊讶、厌恶和中性七种基本情绪,并提供可靠的置信度评分。由强大的DistilRoBERTa模型驱动,它快速、免费且精准,是您提升应用用户体验的理想选择。
“让您的JavaScript应用不仅能处理信息,更能感知情感。”
🎯 核心特性:简单、强大、无处不在
我们致力于让情感分析变得前所未有的简单和高效。
- 🔥 精准情感识别: 识别喜悦、悲伤、愤怒等七大情绪,并给出量化评分。
- 🚀 DistilRoBERTa驱动: 采用前沿AI模型,确保高准确性和可靠性。
- ⚡ 轻量级 & 零依赖: 纯TypeScript客户端,Node.js和浏览器环境无缝运行。
- 🎯 简单易用API: 提供
analyze()和analyzeBatch()方法,上手快,集成更简单。 - 🌐 通用性支持: 兼容Node.js (18+) 和所有主流浏览器。
- 🔷 完善的TypeScript支持: 包含完整的类型定义,开发体验流畅。
- 🛡️ 内置验证机制: 自动执行字数校验,确保API调用高效准确。
- 🔧 高度可配置: 可自定义Base URL,支持自托管实例。
🛠️ 快速上手:只需几行代码
安装
您可以通过以下包管理器轻松安装:
npm install emotion-detector-js
yarn add emotion-detector-js
pnpm add emotion-detector-js
分析单个文本
轻松获取文本的主要情绪:
import { EmotionAnalyzer } from 'emotion-detector-js';
const analyzer = new EmotionAnalyzer();
const result = await analyzer.analyze("I'm so happy today!");
console.log(result.primaryEmotion); // 例如: "joy"
console.log(result.confidence); // 例如: 0.95
详细结果包含所有情绪的得分:
const result = await analyzer.analyze("I'm feeling great about this project!");
console.log(result);
// {
// primaryEmotion: "joy",
// confidence: 0.92,
// allEmotions: [
// { emotion: "joy", score: 0.92 },
// { emotion: "surprise", score: 0.05 },
// { emotion: "neutral", score: 0.03 }
// ]
// }
批量分析文本
一次性分析多个文本,提高效率:
const results = await analyzer.analyzeBatch([
"I'm so excited about the new features!",
"This is really frustrating.",
"I don't know what to think about this."
]);
results.results.forEach((result, index) => {
console.log(`Text ${index + 1}: ${result.primaryEmotion} (${result.confidence})`);
});
自定义配置
可以配置API的基础URL和请求超时时间:
const analyzer = new EmotionAnalyzer({
baseUrl: 'https://your-custom-url.com', // 自托管实例
timeout: 10000 // 请求超时时间 (毫秒)
});
📊 使用限制
为了保证服务质量和公平使用,我们设置了一些合理的限制:
- 单次分析: 每段文本最多100个词。
- 批量分析: 每次最多分析10段文本,每段文本最多100个词。
- 速率限制:
- 单次分析:30次请求/分钟
- 批量分析:10次请求/分钟
handleError 处理错误:优雅应对异常
我们提供了一系列特定的错误类,帮助您构建健壮的应用:
ValidationError: 输入验证失败(例如,文本过长)。RateLimitError: 达到速率限制 (HTTP 429)。ApiError: API返回错误响应。TimeoutError: 请求超时。NetworkError: 网络连接错误。
import {
EmotionAnalyzer,
ValidationError,
RateLimitError,
ApiError,
TimeoutError,
NetworkError
} from 'emotion-detector-js';
const analyzer = new EmotionAnalyzer();
try {
const result = await analyzer.analyze("您的文本");
} catch (error) {
if (error instanceof ValidationError) {
console.error('验证错误:', error.message);
} else if (error instanceof RateLimitError) {
console.error('速率限制:', error.retryAfter, '秒后重试');
} else if (error instanceof ApiError) {
console.error('API错误:', error.message, '状态码:', error.statusCode);
} else if (error instanceof TimeoutError) {
console.error('请求超时:', error.timeout, 'ms');
} else if (error instanceof NetworkError) {
console.error('网络错误:', error.message);
}
}
有了「Emotion Tone Analyzer」,您的应用将不再只是功能性的工具,更是能够理解和回应用户情感的智能伙伴。立即集成,让您的产品脱颖而出!
产品评分
暂无评分
登录后即可评分















