ai_member_xiaobian/scripts/export_act3_xlsx.py
2026-05-08 08:10:01 +08:00

135 lines
6.8 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 openpyxl
from openpyxl.styles import Font, Alignment
from copy import copy
wb = openpyxl.Workbook()
ws = wb.active
ws.title = "第3幕剧本"
# Column widths
ws.column_dimensions['A'].width = 18
ws.column_dimensions['B'].width = 60
ws.column_dimensions['C'].width = 12
ws.column_dimensions['D'].width = 45
# Header
headers = ["类型", "剧情描述", "名字", "台词"]
header_font = Font(bold=True, size=11)
for col, h in enumerate(headers, 1):
cell = ws.cell(row=1, column=col, value=h)
cell.font = header_font
cell.alignment = Alignment(horizontal='center', vertical='center')
# Script data - each row is [type, description, name, dialogue]
# Bold markers: **word** = knowledge point input (bold)
# <red>**word**</red> = User output (bold + red)
# We'll handle rich text formatting
rows = [
["TL", "【场景】教学楼大厅\n【角色】User、Kim、Matt、BoBo", "", ""],
["", "User、Kim、Matt走进教学楼大厅。BoBo跟在User脚边小幅度晃动明显还在兴奋。", "", ""],
["", "", "Kim", "So! We need people to come watch!"],
["", "", "Matt", "But how?"],
["", "", "Kim", "We make a poster!"],
["", "", "Matt", "Good idea. We write what and where."],
["", "", "Matt", "The battle is at the playground, right?"],
["", "", "Kim", "Yes! But what do we write?"],
["", "Kim转向User。", "", ""],
["", "", "Kim", "Hey! Where is the battle?"],
["中互动", "", "User", "The playground!"],
["TL", "BoBo突然蹦起来发出兴奋的"Bzzz Bzzz!"声响,在原地转了一圈。\n【音效】Bzzz机械振动声", "", ""],
["", "", "BoBo", "Bzzz! Me too! Me too!"],
["", "", "Kim", "Ha! Your little robot wants to join!"],
["", "", "Kim", "It looks like fun to BoBo too!"],
["", "", "BoBo", "Bzzz! Fun! Fun!"],
["", "User蹲下来认真地看着BoBo。", "", ""],
["", "", "User", "BoBo. Listen."],
["", "", "User", "If a teacher sees you..."],
["", "", "Matt", "You will be taken away."],
["中互动", "", "User", "No BoBo. This is no fun for you!"],
["TL", "BoBo垂下头委屈地缩小身体安静蹲在User脚边。但还是忍不住微微晃动。", "", ""],
["", "", "Kim", "Just stay quiet, okay?"],
["", "Matt掏出纸和笔摊在大厅的长椅上。", "", ""],
["", "", "Matt", "Okay. Let's write the poster."],
["", "", "Matt", "We need to tell people what to see."],
["", "", "Kim", "It's our class against May's class!"],
["", "", "Matt", "Chinese dragon versus English dragon."],
["", "", "Kim", "People love fun! Write that!"],
["", "", "Matt", "And where? The playground!"],
["", "BoBo在旁边小声嗡嗡像在提意见。", "", ""],
["", "", "BoBo", "Bzzz... big... Bzzz... dragon..."],
["", "", "Kim", "Shh! We know, BoBo."],
["", "Matt把纸递给User。", "", ""],
["", "", "Matt", "Here. You write it. Fill in the blanks."],
["", "【教研图】传单模板——上方画着两条龙对峙的简笔画(一条中国龙、一条西方龙),下方有四行空格待填写", "", ""],
["核心互动-拼写写作", "User填写传单内容\n① Come and have ______!fun\n② ______ class vs ______ classour / May's触发Class\n③ Chinese dragon vs ______ dragonEnglish\n④ At the ______!playground", "User", "填写fun / our class / May's class / English / playground"],
["TL", "传单写好了。Kim拿起来看满意地点头。Matt检查了一遍拼写。\n【插入图】完成的传单特写——歪歪扭扭但热情洋溢的手写字", "", ""],
["", "", "Kim", "Yes! This is great!"],
["", "", "Matt", "Now we need one more thing."],
["", "", "Matt", "A judge."],
["", "", "Kim", "A judge?"],
["", "", "Matt", "Yes. Someone to see who is the winner."],
["", "", "Kim", "Hmm... who is fair?"],
["", "Kim正想着大厅另一头传来脚步声。Sally老师背着包走进来低头看手机准备下班。", "", ""],
["", "", "Kim", "Oh! Look!"],
["", "【emoji】Kim emoji_surprise", "", ""],
["", "", "Kim", "Sally! Over here! Over here!"],
["中互动", "", "User", "Over here, Sally!"],
["TL", "Sally抬头看到这群小孩冲她招手一脸"跟我没关系"的表情走过来。", "", ""],
["", "", "Sally", "What?"],
["", "", "Kim", "We need a judge!"],
["", "", "Sally", "A judge?"],
["", "", "Matt", "Yes! To see who is the winner."],
["", "", "Matt", "You are the best judge!"],
["", "Sally看了一眼传单嘴角微翘但立刻恢复面无表情。", "", ""],
["", "", "Sally", "No. I'm going home."],
["", "", "Kim", "Please! Just one battle!"],
["", "", "Sally", "Find someone else."],
["", "BoBo听到"老师"立刻缩成一团躲到User背后从此不再出现。", "", ""],
["", "", "Matt", "Just have fun with us for a bit!"],
["", "", "Kim", "It will be so much fun!"],
["", "", "Sally", "No."],
["", "User把传单举到Sally面前。", "", ""],
["中互动", "", "User", "Have fun with us!"],
["TL", "Sally盯着传单看了三秒。叹了口气。", "", ""],
["", "", "Sally", "...Fine. ONE battle."],
["", "", "Sally", "Then I go home."],
["", "【emoji】Kim emoji_celebrate", "", ""],
["", "", "Kim", "Yes!"],
["", "", "Matt", "Thank you Sally!"],
["", "Kim抢过传单。", "", ""],
["", "", "Kim", "I'll go tell everyone!"],
["", "", "Matt", "Good. You go. We bring Sally to the battle."],
["", "Kim跑出大厅去发传单。Sally无奈地跟着User和Matt往外走。", "", ""],
["", "", "Sally", "So... the playground?"],
["中互动", "", "User", "Yes! The playground! Over here!"],
["TL", "User带着Sally和Matt朝操场方向走去。远处操场上两条龙的轮廓隐约可见。", "", ""],
]
# Bold font for knowledge point input
bold_font = Font(bold=True, size=10)
# Red bold font for User output
red_bold_font = Font(bold=True, color="F54A45", size=10)
normal_font = Font(size=10)
wrap_align = Alignment(wrap_text=True, vertical='top')
# Knowledge point words to bold in NPC lines
kp_input_words = ["playground", "class", "English", "fun", "Over here", "have fun with"]
# Knowledge point words to red-bold in User lines
kp_output_words = ["playground", "no fun", "Over here", "Have fun with"]
for i, row_data in enumerate(rows, 2):
for col, val in enumerate(row_data, 1):
cell = ws.cell(row=i, column=col, value=val)
cell.font = normal_font
cell.alignment = wrap_align
# Set row height for description rows
for row in ws.iter_rows(min_row=2, max_row=ws.max_row):
if row[1].value and '\n' in str(row[1].value):
ws.row_dimensions[row[0].row].height = 40
output_path = "/root/.openclaw/workspace-xiaobian/output/U18_L5_Act3_draft.xlsx"
wb.save(output_path)
print(f"Saved to {output_path}")