generate_seed.py
8.47 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import json
import random
from datetime import datetime, timezone
subreddits = {
"AmITheAsshole": {
"templates": [
("AITA for telling my {relation} that their {obj} is {adj}?", "My {relation} has this {obj} that they treasure...", "moral_dilemma"),
("WIBTA if I {action} at {event}?", "I (28F) have been planning this for months...", "social_conflict"),
("AITA for refusing to {action} for my {relation}?", "So here's the situation. I work full time...", "boundary_setting"),
],
"relation": ["sister", "brother", "mother-in-law", "roommate", "coworker", "best friend", "aunt", "stepmom"],
"obj": ["wedding dress", "cooking", "new car", "baby name", "house rules", "diet", "hobby", "opinion"],
"adj": ["ugly", "unhealthy", "inappropriate", "overpriced", "ridiculous", "embarrassing"],
"action": ["skip the wedding", "speak up", "move out", "call the police", "refuse to apologize", "quit the group chat"],
"event": ["the family dinner", "the wedding", "the work meeting", "Thanksgiving", "the baby shower", "the funeral"],
},
"relationship_advice": {
"templates": [
("My ({age}M) partner ({age2}F) {action} and I don't know how to feel", "We've been together for {years} years...", "trust_issue"),
("I think my {relation} is {action}, what should I do?", "I found some messages on their phone...", "betrayal"),
("How do I tell my {relation} that I {feeling} without hurting them?", "This has been weighing on me for months...", "communication"),
],
"relation": ["boyfriend", "girlfriend", "husband", "wife", "fiancé", "partner of 3 years"],
"action": ["cheating on me", "lying about their job", "keeping texting their ex", "not wanting kids", "wanting to move across the country"],
"feeling": ["want to break up", "don't love them anymore", "need space", "am not attracted to them"],
},
"funny": {
"templates": [
("{subject} {action} and I can't stop laughing", "So this just happened at work...", "observational_humor"),
("My {subject} {action}. That's it. That's the post.", "No context needed.", "absurdist"),
("Who else remembers {thing}?", "Found this gem in my grandparents' attic.", "nostalgia"),
],
"subject": ["my cat", "my boss", "this random dude", "my grandma", "the delivery guy", "an AI"],
"action": ["tried to parallel park", "fell asleep in a meeting", "sent me a meme at 3am", "dressed up as a banana"],
"thing": ["floppy disks", "dial-up internet", "Blockbuster", "Tamagotchis", "Nokia phones"],
}
}
def rand_date():
now = datetime.now(timezone.utc)
delta = random.randint(0, 604800)
return (now.timestamp() - delta)
def generate_post(subreddit, idx):
cfg = subreddits[subreddit]
tpl = random.choice(cfg["templates"])
title_template, body_template, conflict_type = tpl
kwargs = {}
for k, v in cfg.items():
if k != "templates":
kwargs[k] = random.choice(v)
if subreddit == "relationship_advice":
age = random.randint(22, 38)
age2 = age + random.randint(-3, 5)
years = random.randint(1, 8)
kwargs["age"] = age
kwargs["age2"] = age2
kwargs["years"] = years
title = title_template.format(**kwargs)
body = body_template.format(**kwargs)
if random.random() > 0.5:
body += "\n\nEdit: Thanks for the responses."
score = random.randint(500, 45000) if subreddit != "funny" else random.randint(1200, 85000)
num_comments = int(score * random.uniform(0.05, 0.45))
upvote_ratio = round(random.uniform(0.72, 0.98), 2)
post_id = f"{subreddit[:3].lower()}{random.randint(100000, 999999)}"
created_ts = rand_date()
if subreddit == "AmITheAsshole":
characters = [
{"role": "Protagonist", "archetype": "conflicted everyman"},
{"role": "Antagonist", "archetype": random.choice(["entitled relative", "oblivious coworker", "demanding in-law"])}
]
elif subreddit == "relationship_advice":
characters = [
{"role": "OP", "archetype": "betrayed partner"},
{"role": "Partner", "archetype": random.choice(["secretive lover", "commitment-phobe", "gaslighter"])}
]
else:
characters = [
{"role": "Subject", "archetype": random.choice(["clueless boomer", "chaotic pet", "absurdist everyman"])}
]
setting = random.choice([
"domestic living room", "office conference room", "family dinner table",
"car on highway", "wedding venue", "hospital waiting room", "grocery store"
])
conflict = random.choice([
"lies exposed at the worst moment",
"boundary crossed for the final time",
"social faux pas escalates",
"unexpected third party intervenes",
"secret revealed through technology"
])
dialogue = random.choice([
'"You should have told me the truth."',
'"I can\'t believe you did that in front of everyone."',
'"This is exactly why I never wanted to come here."',
'"If you really loved me, you would have known."',
'"I was just trying to help!"'
])
twist = random.choice([
"The innocent party was actually complicit",
"A misunderstanding spiraled because of group chat",
"The villain had a tragic backstory",
"Technology (phone/AI) accidentally revealed everything"
])
emotion_arc = random.choice([
"resentment → shock → righteous anger",
"confusion → suspicion → devastation → resolve",
"amusement → absurdity → viral catharsis",
"embarrassment → defensiveness → reluctant acceptance"
])
base_drama = (min(score, 20000) / 20000) * 30 + upvote_ratio * 20
comment_density = min(num_comments / 500, 20)
conflict_bonus = {
"moral_dilemma": 12, "social_conflict": 10, "boundary_setting": 8,
"trust_issue": 14, "betrayal": 16, "communication": 6,
"observational_humor": 4, "absurdist": 5, "nostalgia": 3
}.get(conflict_type, 5)
drama_score = round(base_drama + comment_density + conflict_bonus + random.uniform(-2, 2), 1)
drama_score = max(0, min(100, drama_score))
permalink = f"/r/{subreddit}/comments/{post_id}/"
return {
"post_id": post_id,
"source": {
"platform": "reddit",
"subreddit": subreddit,
"permalink": permalink,
"source_url": f"https://www.reddit.com{permalink}",
"crawl_time": datetime.now(timezone.utc).isoformat()
},
"engagement": {
"score": score,
"num_comments": num_comments,
"upvote_ratio": upvote_ratio,
"awards": random.randint(0, 12)
},
"content": {
"title": title,
"body": body,
"author": f"u/throwaway_{random.randint(1000,9999)}",
"created_utc": created_ts,
"is_nsfw": False,
"is_spoiler": False
},
"drama_elements": {
"characters": characters,
"setting": setting,
"conflict_type": conflict_type,
"conflict_summary": conflict,
"key_dialogue": dialogue,
"plot_twist": twist,
"emotion_arc": emotion_arc
},
"script_potential": {
"drama_score": drama_score,
"genre_suggestion": random.choice([
"domestic drama", "romantic tragedy", "office comedy",
"family feud", "tiktok skit", "reveal video"
]),
"estimated_duration_sec": random.choice([30, 45, 60, 90, 120]),
"visual_hooks": random.sample([
"reaction shot", "text message reveal", "door slam",
"zoom on face", "split screen argument", "flashback montage",
"overheard conversation", "public meltdown"
], k=3),
"target_demographics": random.choice([
["18-24F", "25-34F"],
["18-24M", "18-24F"],
["25-34 All"],
["13-17 All"]
])
}
}
random.seed(42)
posts = []
for sub in ["AmITheAsshole", "relationship_advice", "funny"]:
count = 16 if sub == "funny" else 17
for i in range(count):
posts.append(generate_post(sub, i))
random.shuffle(posts)
with open("seed_data.json", "w", encoding="utf-8") as f:
json.dump(posts, f, ensure_ascii=False, indent=2)
print(f"Generated {len(posts)} seed posts")