dict: """テキストの感情分析を行う""" # 実際の実装では感情分析APIを使用 # ここではシンプルな例として、ポジティブ/ネガティブワードのカウントで代用 positive_words = ["良い", "素晴らしい", "嬉しい", "楽しい", "好き"] negative_words = ["悪い", "ひどい", "悲しい", "嫌い", "残念"] positive_count = sum(1 for word in positive_words if word in text) negative_count = sum(1 for word in negative_words if word in text) # スコアの計算(-1.0〜1.0の範囲) total = positive_count + negative_count if total == 0: score = 0.0 else: score = (positive_count - negative_count) / total return { "sentiment": "positive" if score > 0 else "negative" if score < 0 else "neutral", "score": score, "positive_count": positive_count,