32 lines
1.2 KiB
Python
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]}...")
|