text/test_analysis.py
朱指乐 aa10e463b4 feat: 初始化垃圾短信分类项目基础结构
添加项目核心文件结构,包括:
- 配置文件和环境变量管理
- 数据处理和翻译模块
- 机器学习模型训练和评估
- 基于LLM的智能分析Agent
- 测试脚本和项目文档
2026-01-14 00:18:34 +08:00

32 lines
1.2 KiB
Python

import sys
import os
# 添加src目录到Python路径
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
from simple_agent import SimpleSpamAnalysis
# 测试短信
test_messages = [
"Free entry in 2 a wkly comp to win FA Cup final tkts 21st May 2005. Text FA to 87121 to receive entry question(std txt rate)T&C's apply 08452810075over18's",
"Ok lar... Joking wif u oni...",
"WINNER!! As a valued network customer you have been selected to receivea £900 prize reward! To claim call 09061701461. Claim code KL341. Valid 12 hours only."
]
# 初始化分析系统
analyzer = SimpleSpamAnalysis()
# 分析短信
for i, message in enumerate(test_messages):
print(f"\n=== 短信分析结果 {i+1} ===")
result = analyzer.analyze(message)
print(f"原始短信: {result['original_message'][:100]}...")
print(f"中文翻译: {result['translated_message'][:100]}...")
print(f"分类结果: {result['classification']['label']} (置信度: {result['classification']['confidence']:.2f})")
print(f"关键词: {', '.join(result['key_words'])}")
print(f"原因: {result['reason']}")
print(f"建议: {result['suggestion']}")
print(f"详细解释: {result['detailed_explanation'][:200]}...")