GROUP123-LYT/test_keyword_fix.py
DROUP123 72bec8db47 feat: 初始化海龟汤游戏项目,包含核心逻辑、前端界面和文档
- 添加核心游戏逻辑文件structual.py,实现海龟汤游戏基本功能
- 创建HTML前端界面turtle_soup_html.html,提供交互式游戏体验
- 编写详细README.md文档,包含项目介绍、运行指南和贡献说明
- 添加项目配置文件pyproject.toml和环境变量示例
- 实现游戏数据存储功能,使用JSON保存游戏记录
- 包含15个预设海龟汤题目和关键词匹配系统
2026-01-07 15:16:59 +08:00

52 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# 测试关键词修复脚本
import sys
import os
# 添加当前目录到sys.path
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
# 直接导入structual模块
import structual
def test_keyword_fix():
"""测试关键词修复"""
print("=== 测试关键词修复 ===")
# 创建游戏实例
game = structual.TurtleSoupGame()
# 手动设置代孕相关的故事第12个故事索引11
target_story_index = 11
game.story = game.DEFAULT_STORIES[target_story_index]["scenario"]
game.solution = game.DEFAULT_STORIES[target_story_index]["solution"]
print(f"\n选择的故事:{game.story}")
print(f"答案:{game.solution}")
# 测试问题列表
test_questions = [
"涉及代孕吗?",
"这个女人是代孕妈妈吗?",
"是否有代孕相关的内容?",
"孩子的父亲存在吗?",
"这是关于犯罪的吗?"
]
print("\n=== 测试问题和回答 ===")
for question in test_questions:
# 调用实际的answer_question方法
answer = game.answer_question(question)
print(f"问题:{question}")
print(f"回答:{answer}")
# 检查关键修复点
if "代孕" in question.lower() and answer == "":
print("✅ 关键修复:'代孕'关键词匹配成功!")
print("\n=== 测试完成 ===")
if __name__ == "__main__":
test_keyword_fix()