generate_seed.py
7.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/usr/bin/env python3
"""Generate seed_data.json for lemonv_drama - 古风互动剧本生成系统"""
import json
import random
from datetime import datetime, timezone, timedelta
random.seed(7)
eras = ["唐", "宋", "明", "清", "仙侠", "架空"]
genres = ["宫廷", "武侠", "仙侠", "民间", "神话", "穿越"]
emotions = ["绮丽境", "雄浑境", "冲淡境", "凄婉境"]
settings_tang = ["长安城", "大明宫", "扬州", "洛阳"]
settings_song = ["汴京", "临安", "江南小镇"]
settings_ming = ["京城", "江南", "边关"]
settings_xianxia = ["昆仑山", "蓬莱仙岛", "青云宗"]
settings_qing = ["京城", "苏州", "江南织造"]
setting_pool = {
"唐": settings_tang, "宋": settings_song, "明": settings_ming,
"仙侠": settings_xianxia, "清": settings_qing, "架空": ["云隐城", "天枢阁"]
}
moods = ["盛大繁华", "暗流涌动", "凄美离别", "热血激昂", "温馨治愈", "悬疑紧张"]
endings = ["HE", "BE", "NE", "TE"]
protagonists = [
"废柴嫡女", "冷面王爷", "神医圣手", "江湖少侠", "穿越女主", "将军嫡子",
"腹黑谋士", "热血剑客", "傲娇公主", "憨厚书生", "天才少女", "失忆高手"
]
antagonists = [
"恶毒继母", "阴谋皇子", "武林盟主", "朝堂权臣", "灭门仇人", "前世宿敌",
"白切黑闺蜜", "伪善师父", "灭族仇敌", "心机表妹"
]
deuteragonists = [
"忠诚暗卫", "温柔竹马", "高冷师兄", "阳光小师弟", "神秘高人", "俏皮丫鬟",
"痴情男配", "正义捕快", "神秘商人", "忠义老仆"
]
ai_producibility_tips = [
"室内宫廷场景为主,AI生成难度低",
"武侠动作戏较多,建议真人实拍或简化",
"仙侠特效场景密集,AI生成成本高",
"明清室内场景,AI生成可行",
"大量外景和战争场面,AI生成受限"
]
dialogue_styles = ["文言化", "半文半白", "古典白话", "诗意对白"]
def make_plot_twist(era):
twists = [
"身份逆转:主角发现自己的真实身份远超想象",
"青梅竹马实为仇人之子,多年陪伴是一场阴谋",
"身世之谜:以为的废柴,其实是皇室血脉",
"替身文学:心上人的白月光竟是自己的替身",
"重生复仇:带着前世记忆回到关键节点",
"男二是好人的反转",
"反派洗白:宿敌竟是卧底守护者",
"失忆梗:忘记的是最不该忘的人",
"假死脱身:所有人都以为他死了",
"狸猫换太子式的亲子鉴定反转",
]
return random.choice(twists)
def make_emotion_arc(emotion):
arcs = {
"绮丽境": ["初见惊艳", "试探拉扯", "互诉衷肠", "误会虐恋", "真相大白", "执子之手"],
"雄浑境": ["家国危难", "临危受命", "浴血奋战", "功成名就", "隐退江湖"],
"冲淡境": ["误入桃源", "渐生情愫", "身份暴露", "归隐山林", "相守一生"],
"凄婉境": ["偶遇倾心", "阴谋陷害", "生离死别", "孤身复仇", "真相大白", "阴阳两隔"],
}
return random.choice(list(arcs.values()))
def generate_drama(idx):
era = random.choice(eras)
genre = random.choice(genres)
emotion = random.choice(emotions)
setting = random.choice(setting_pool.get(era, ["京城"]))
mood = random.choice(moods)
protagonist = random.choice(protagonists)
antagonist = random.choice(antagonists)
deuteragonist = random.choice(deuteragonists)
era_descriptions = {
"唐": "盛世繁华,胡汉交融,文化开放",
"宋": "文人治国,市井经济繁荣,商业发达",
"明": "厂卫制度,海禁与走私并存,党争激烈",
"清": "宫廷制度森严,满汉矛盾,文字狱盛行",
"仙侠": "灵气复苏,宗门林立,弱肉强食",
"架空": "规则自由,不受历史约束",
}
title_templates = [
f"《{era}朝{protagonist}》",
f"《{mood}:{antagonist}与{protagonist}》",
f"《{setting}往事》",
f"《{genre}志:{deuteragonist}的抉择》",
f"《{era}梦华录》",
f"《{antagonist}的一千零一种死法》",
]
ending_types = random.sample(endings, k=random.randint(2, 4))
word_count = random.choice([3000, 5000, 8000, 12000, 20000])
branch_count = random.randint(2, 6)
branch_nodes = []
for b in range(branch_count):
node = {
"node_id": f"BRANCH_{idx}_{b+1}",
"plot_summary": random.choice([
f"关键抉择:是否相信对方?",
f"危机时刻:如何应对突如其来的陷害?",
f"情感考验:利益与情义的选择",
f"身份揭露:真相浮出水面的瞬间",
f"生死抉择:牺牲自己还是牺牲对方?",
f"阵营站队:各方势力的拉拢",
]),
"choice_count": random.randint(2, 3),
"consequence_preview": random.choice([
"命运的齿轮开始转动",
"一条看似光明实则危险的道路",
"表面是敌人,实则是盟友",
"触发了隐藏条件的判定",
])
}
branch_nodes.append(node)
genre_ai_map = {
"宫廷": 7, "武侠": 6, "仙侠": 5, "民间": 8, "神话": 5, "穿越": 7
}
ai_prod = genre_ai_map.get(genre, 6)
ai_score = ai_prod * 5 + random.uniform(-5, 5)
ai_tip = ai_producibility_tips[genres.index(genre)] if genre in genres[:len(ai_producibility_tips)] else random.choice(ai_producibility_tips)
script_potential = {
"genre": genre,
"ai_producibility_score": round(max(0, min(50, ai_score)), 1),
"ai_producibility_tip": ai_tip,
"branch_count": branch_count,
"ending_count": len(ending_types),
"emotion": emotion,
"era": era,
"setting": setting,
"mood": mood,
}
return {
"drama_id": f"drama_{idx:03d}",
"title": random.choice(title_templates),
"source": {
"platform": "lemonv_drama",
"type": "古风互动剧本",
"era": era,
"genre": genre,
"emotion": emotion,
"source_url": "lemonv_drama:seed_generation",
"crawl_time": datetime.now(timezone.utc).isoformat()
},
"content": {
"protagonist": protagonist,
"antagonist": antagonist,
"deuteragonist": deuteragonist,
"setting": f"{era}朝{setting}",
"era_description": era_descriptions.get(era, ""),
"plot_twist": make_plot_twist(era),
"emotion_arc": make_emotion_arc(emotion),
},
"structure": {
"word_count": word_count,
"branch_count": branch_count,
"ending_types": ending_types,
"branch_nodes": branch_nodes,
"dialogue_style": random.choice(dialogue_styles),
},
"script_potential": script_potential,
}
dramas = [generate_drama(i) for i in range(1, 52)]
with open("seed_data.json", "w", encoding="utf-8") as f:
json.dump(dramas, f, ensure_ascii=False, indent=2)
print(f"Generated {len(dramas)} lemonv_drama seed entries")