ai_member_xiaoban/generate_teaching_scheme.py
2026-03-14 08:00:01 +08:00

73 lines
3.4 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.

import pandas as pd
# 你提供的核心逻辑适配Excel输入输出
def process_vocabulary_system(file_path):
# 1. 加载Excel数据
try:
df = pd.read_excel(file_path)
except FileNotFoundError:
return "Error: File not found."
df.columns = [c.strip() for c in df.columns]
print(f"加载文件成功,共{len(df)}条单词记录")
# 2. 你定义的特殊规则
t2_special_list = {
'invisible': {'air', 'wind', 'smoke', 'gas'},
'abstract': {'song', 'friend', 'hobby', 'art', 'pe', 'music', 'fun'},
'generalized': {'child', 'children', 'father', 'mother', 'food', 'colour', 'animal', 'toy'},
'identity': {'address', 'age', 'aunt', 'name'}
}
# 预展开T2特殊词集合
all_t2_special = {item for sublist in t2_special_list.values() for item in sublist}
# 3. 核心处理逻辑
def apply_rules(row):
# 清洗输入
word = str(row.get('单词', '')).lower().strip()
t_score = pd.to_numeric(row.get('实现成本(T)', 1), errors='coerce')
if pd.isna(t_score):
t_score = 1
# 规则分支
if t_score >= 3:
scheme = "逻辑交互 / UI 处理"
reason = "英语骨架词。涉及空间位置、时序或数量的逻辑判定需系统重度UI引导。"
link = "建议设计‘解谜指令’,如:利用 here/there 进行远近空间坐标对比任务。"
elif t_score == 2 or word in all_t2_special:
scheme = "动画 / 特效 / UI处理"
if word in t2_special_list['invisible']:
reason = "隐形名词。需环境联动(如风吹树叶)和特效辅助表现。"
link = "联动关联实物wind 联动 tree/leaf 的动态表现。"
elif word in t2_special_list['generalized']:
reason = "泛化概念。无法用单一图片代表需UI组合展示或多模型联动。"
link = f"联动具体成员,由 {word} 展示其下属的 T1 级具象单词集合。"
elif word in t2_special_list['abstract'] or word in t2_special_list['identity']:
reason = "抽象/身份信息。需通过情节演绎或特定 UI 界面(如家谱)界定。"
link = "联动相关动作song 联动 singage 联动 numbers。"
else:
reason = "动作/状态词。需 Animator 动画、粒子特效或角色表情反馈。"
link = "建议设计状态切换任务open vs closeddirty vs clean。"
else: # T1 情况
scheme = "静态模型展示"
reason = "具象实物。在 Unity 中对应单一、静态的物理模型或材质资源。"
link = "可作为背景或道具。建议联动颜色词或方位词增加任务厚度。"
return pd.Series([scheme, reason, link])
# 执行规则生成新列
df[['教学方案展示', '实现理由', '联动建议']] = df.apply(apply_rules, axis=1)
# 4. 导出为Excel
output_file = "/root/.openclaw/workspace-xiaoban/LV1词汇教学方案生成结果.xlsx"
df.to_excel(output_file, index=False)
return f"Success: 处理完成,结果已保存到 {output_file}"
# 处理刚收到的LV1词汇表
input_path = "/root/.openclaw/media/inbound/â_¼ï_LV1-å_ç_å_è_åº_-ç¼_å_é_è_ç_è_é---d41d887f-5d65-4eab-928d-a717e5097e8c.xlsx"
result = process_vocabulary_system(input_path)
print(result)