

✨ Emotion Tone Analyzer:让JavaScript更有温度的AI情感引擎 ✨
有没有想过,您的应用也能读懂用户的心情?「Emotion Tone Analyzer」正是为此而生!这款基于尖端AI技术的情感分析工具,让您的JavaScript应用瞬间拥有强大的情感洞察力,为用户带来更个性化、更贴心的体验。
「Emotion Tone Analyzer」利用先进的AI技术,深入剖析文本的细微情感。它能精准识别快乐、悲伤、愤怒、恐惧、惊讶、厌恶和中性七种基本情绪,并提供可靠的置信度评分。由强大的DistilRoBERTa模型驱动,它快速、免费且精准,是您提升应用用户体验的理想选择。
“让您的JavaScript应用不仅能处理信息,更能感知情感。”
我们致力于让情感分析变得前所未有的简单和高效。
analyze()和analyzeBatch()方法,上手快,集成更简单。您可以通过以下包管理器轻松安装:
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 // 请求超时时间 (毫秒)
});
为了保证服务质量和公平使用,我们设置了一些合理的限制:
我们提供了一系列特定的错误类,帮助您构建健壮的应用:
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」,您的应用将不再只是功能性的工具,更是能够理解和回应用户情感的智能伙伴。立即集成,让您的产品脱颖而出!