long-div / scripts /generate_tier2_batch02.py
ymyy307's picture
Upload folder using huggingface_hub
5b12ab1 verified
Raw History Blame Contribute Delete
24.3 kB
#!/usr/bin/env python3
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
OUT = ROOT / "generated" / "tier2_batch02.json"
def shot(no, visible, visual, sound, dialogue=None):
return {"shot_no": no, "visible_characters": visible, "visual": visual,
"sound": sound, "dialogue": dialogue or []}
def line(character, text):
return {"character": character, "language": "English", "text": text}
def compile_case(meta):
chars = meta["characters"]
speaking_seen = set()
appeared_seen = set()
compiled = []
for raw in meta.pop("shot_specs"):
visible = raw["visible_characters"]
dialogue = raw["dialogue"]
speakers = list(dict.fromkeys(item["character"] for item in dialogue))
first = [speaker for speaker in speakers if speaker not in speaking_seen]
speaking_seen.update(speakers)
subject = {char: index + 1 for index, char in enumerate(visible)}
dialogue_block = ""
for speech_index, item in enumerate(dialogue, start=1):
dialogue_block += (
f"\n\n<Subject {subject[item['character']]}> (S{speech_index}) says: "
f"<d>[English] {item['text']}</d>"
)
if raw["shot_no"] == 1:
introductions = " ".join(
f"<Subject {subject[char]}> is {chars[char]}." for char in visible
)
prompt = (
"integrated_multimodal_description:\n"
f"[Shot 1] {introductions} {raw['visual']}"
f"{dialogue_block}\n\noverall_soundscape:\n{raw['sound']}"
)
else:
definitions = "\n".join(
f"<Subject {subject[char]}> is {chars[char]}." for char in visible
)
retention = "\n".join(
f"<Subject {subject[char]}>: fully_preserved - Maintain identity."
for char in visible if char in appeared_seen
)
retention_block = f"{retention}\n" if retention else ""
prompt = (
f"subject_definitions:\n{definitions}\n{{{{REFERENCE_DEFINITIONS}}}}"
"\n\nsummary:\n{{REFERENCE_SUMMARY}}"
f"\n\nretention_analysis:\n{retention_block}{{{{REFERENCE_RETENTION}}}}"
f"\n\ndetailed_description:\n[Shot 1] {raw['visual']}"
f"{dialogue_block}\n\noverall_soundscape:\n{raw['sound']}"
)
compiled.append({
"shot_no": raw["shot_no"],
"visible_characters": visible,
"speakers": speakers,
"first_time_speakers": first,
"dialogue": dialogue,
"prompt": prompt,
})
appeared_seen.update(visible)
meta["shots"] = compiled
return meta
CASES = [
{
"case_id": "worker_06_tier2", "tier": 2, "target_identity": "<char3>",
"first_appearance_shot": 5, "reappearance_shot": 13, "absence_gap": 7,
"characters": {
"<char1>": "a middle-aged white woman with a chestnut braid, a slate rain shell, brown hiking trousers, and a small canvas daypack",
"<char2>": "an elderly East Asian man with short gray hair, a forest-green vest, beige trousers, and binoculars on a broad black strap",
"<char3>": "a young Indigenous nonbinary nature educator with two long black braids, a rust field jacket, dark waterproof trousers, and cedar-bead earrings"
},
"shot_specs": [
shot(1,["<char1>"],"A wide establishing shot shows <Subject 1> step onto the rain-dark forest boardwalk and slow before a shallow puddle reflecting the canopy.","Water drips from leaves and one hiker speaks.",[line("<char1>","The boards are wet, so I will keep to the center and take the turns slowly.")]),
shot(2,["<char2>"],"At a low observation rail, <Subject 1> lifts his binoculars toward a quiet opening between cedar trunks, then lowers them before walking on.","Distant birds, dripping foliage, and one low voice.",[line("<char2>","A thrush is calling beyond the platform. We do not need to leave the walkway to hear it.")]),
shot(3,["<char1>","<char2>"],"A rear follow shot keeps both walkers full-length as <Subject 1> and <Subject 2> round a broad bend and step around separate puddles.","Measured footfalls and water falling from branches."),
shot(4,["<char2>","<char1>"],"<Subject 1> pauses at the viewing platform while <Subject 2> approaches the mossy fork; both look down at small fungi beside, not on, the boards.","A wooden rail creaks and forest ambience remains soft."),
shot(5,["<char3>","<char1>","<char2>"],"<Subject 1> emerges from behind a cedar at the fork, greets <Subject 2> and <Subject 3>, then takes the short branch path and disappears behind wet ferns.","Fern fronds brush fabric and one clear voice.",[line("<char3>","I will check the short branch path and meet you where the two boardwalks join.")]),
shot(6,["<char1>","<char2>"],"<Subject 1> and <Subject 2> continue on the main boardwalk, passing a cluster of amber fungi while keeping their feet squarely on the planks.","Drips, quiet shoes, and a far birdcall."),
shot(7,["<char1>"],"A medium shot holds <Subject 1> as she stops before a deeper puddle, studies its edge, and crosses with two careful steps along the dry center strip.","A small splash and rainwater beneath the boards."),
shot(8,["<char2>"],"Framed through tree trunks, <Subject 1> watches a bird cross the canopy opening and turns toward the rising section of walkway.","Wingbeats and leaves moving lightly."),
shot(9,["<char1>","<char2>"],"The two walkers climb the gentle boardwalk grade side by side, then separate into single file at a narrow rail section.","Wooden footfalls and subdued wind."),
shot(10,["<char2>","<char1>"],"<Subject 1> points only with his gaze toward fresh shelf fungi while <Subject 2> waits one pace behind, leaving the path unobstructed.","Forest room tone and one brief observation.",[line("<char2>","The new growth is on the fallen trunk ahead, well beyond the walking edge.")]),
shot(11,["<char1>","<char2>"],"A ground-level view shows both pairs of boots pass a clear stretch of boardwalk as the remaining mist lifts from the moss.","Even steps, dripping moss, and no speech."),
shot(12,["<char1>"],"<Subject 1> reaches the final curve and rests one hand on the rail while the two-path junction becomes visible through the trees.","A soft rail touch and distant running water."),
shot(13,["<char3>"],"At the junction, <Subject 1> steps from behind a broad trunk and waits in the open, matching the rust jacket, braids, and cedar earrings seen earlier.","A branch releases droplets and the same educator speaks.",[line("<char3>","The branch path is clear, and the driest return is the boardwalk behind me.")]),
shot(14,["<char1>","<char2>","<char3>"],"The three turn onto the shared return route, with <Subject 3> leading at a relaxed distance and the others following through the brightening forest.","Three sets of footsteps and birdsong; no dialogue.")
]
},
{
"case_id": "worker_07_tier2", "tier": 2, "target_identity": "<char4>",
"first_appearance_shot": 7, "reappearance_shot": 14, "absence_gap": 6,
"characters": {
"<char1>": "an elderly white man with thinning silver hair, a camel overcoat, navy trousers, and a polished wooden cane",
"<char2>": "an elderly Latina woman with a gray bob, a burgundy coat, and a cream scarf",
"<char3>": "a young Black man with short twists, a charcoal hoodie, dark jeans, and round glasses",
"<char4>": "a young East Asian woman with a blunt black bob, a deep red usher jacket, black trousers, and a small brass name pin"
},
"shot_specs": [
shot(1,["<char1>"],"<Subject 1> enters the old cinema lobby and pauses beneath the warm poster lights, looking toward the darker auditorium corridor.","Muted street noise, lobby ventilation, and one voice.",[line("<char1>","I can manage the aisle if the step lights are visible before the trailers begin.")]),
shot(2,["<char2>"],"<Subject 1> comes through the glass doors, lets them close, and studies the cream floor line leading toward the hall.","Door seals and one warm reply.",[line("<char2>","We have time to walk in slowly. I would rather choose the clearer side.")]),
shot(3,["<char3>"],"Beside a poster alcove, <Subject 1> removes his glasses briefly to wipe rain mist, then looks toward the nearly empty corridor.","A cloth touches glass and one quiet voice.",[line("<char3>","I will wait until the doorway clears, then take a seat near the back.")]),
shot(4,["<char1>","<char2>"],"<Subject 1> and <Subject 2> cross the lobby toward the heavy curtain, matching their pace under the changing wall lights.","Carpeted steps and distant projector ventilation."),
shot(5,["<char3>"],"<Subject 1> follows later through the corridor, his silhouette passing beneath three low sconces as the auditorium door comes into view.","Soft shoes and a faint trailer tone beyond the door."),
shot(6,["<char1>","<char2>","<char3>"],"The three visitors gather with natural spacing before the dark curtain. <Subject 1> tests the first illuminated step with his cane while the others wait.","A cane tip on carpet and low cinema hum."),
shot(7,["<char4>","<char1>","<char2>","<char3>"],"<Subject 1> opens the curtain from inside, reveals the lit aisle, and speaks before accompanying <Subject 2> toward a gentler side route.","Curtain rings, projector hum, and one whispered voice.",[line("<char4>","The side aisle is brighter and has fewer steps. I will walk it with you first.")]),
shot(8,["<char1>","<char3>"],"<Subject 1> enters along the central aisle while <Subject 2> remains near the back row, allowing the step lights to guide their separate positions.","Quiet footfalls and soft screen music."),
shot(9,["<char1>"],"<Subject 1> chooses an aisle seat, turns carefully, and lowers himself while keeping his cane against his own knee.","A seat folds down and projector fans continue."),
shot(10,["<char3>"],"From a low aisle angle, <Subject 1> walks to the back row and sits as pale moving light crosses his face and round glasses.","Muted trailer sound and one seat settling."),
shot(11,["<char2>"],"<Subject 1> appears at the far side aisle and pauses beside a row with generous legroom before taking the end seat.","Soft carpet steps and screen ambience."),
shot(12,["<char1>","<char2>"],"Across several rows, <Subject 1> turns and sees <Subject 2> comfortably seated on the brighter side; both settle facing the screen.","A subdued orchestral trailer and ventilation."),
shot(13,["<char3>"],"<Subject 1> leans back as the screen brightens from blue to warm amber, revealing the empty seats and both clear aisles around him.","Trailer ambience and no dialogue."),
shot(14,["<char4>"],"<Subject 1> enters from the screen-side passage, her red usher jacket and brass pin gradually revealed by the changing screen light.","A curtain brushes and the same whispered voice.",[line("<char4>","The side route is clear, and the house lights will remain at this level until the feature starts.")]),
shot(15,["<char1>","<char2>","<char3>","<char4>"],"A wide rear view holds all four in their separated positions as <Subject 4> moves quietly toward the exit and the visitors face the screen.","House lights dim slightly, projector fans remain, and no speech.")
]
},
{
"case_id": "worker_08_tier2", "tier": 2, "target_identity": "<char3>",
"first_appearance_shot": 5, "reappearance_shot": 12, "absence_gap": 6,
"characters": {
"<char1>": "a young Black woman with long microbraids, a pale denim jacket, olive trousers, and a wicker laundry basket",
"<char2>": "an elderly East Asian man with swept white hair, a navy cardigan, gray trousers, and clothespins in one hand",
"<char3>": "a middle-aged Middle Eastern man with short curly hair, a sand-colored overshirt, dark work trousers, and an empty blue laundry basket"
},
"shot_specs": [
shot(1,["<char1>"],"A wide establishing shot on an apartment roof follows <Subject 1> between billowing sheets as she catches one loose corner before it reaches the parapet.","Wind in fabric and one alert voice.",[line("<char1>","The wind is turning. I will take down the widest sheet before it twists around the line.")]),
shot(2,["<char2>"],"<Subject 1> closes the stair door behind him and watches a row of pillowcases lift together in the new crosswind.","A latch clicks, cloth snaps softly, and one reply.",[line("<char2>","I will start at this end and keep the doorway clear.")]),
shot(3,["<char1>","<char2>"],"The two work from opposite ends of one long sheet, bringing it down in a slow shared fold without using a table or ledge.","Fabric folds and rooftop wind."),
shot(4,["<char2>","<char1>"],"<Subject 1> carries folded cloth toward the stair wall while <Subject 2> walks deeper between the moving lines with her basket.","Footsteps, basket weave, and sheets fluttering."),
shot(5,["<char3>","<char1>","<char2>"],"<Subject 1> appears at the roof door with an empty blue basket, speaks, then crosses to the neighboring terrace where a light door taps in the wind.","A door taps, fabric moves, and one neighbor speaks.",[line("<char3>","I will secure the terrace latch, then come back through the far laundry row.")]),
shot(6,["<char1>","<char2>"],"<Subject 1> and <Subject 2> release a second sheet together and let it settle into the wicker basket between them.","Wind, fabric, and a basket creak."),
shot(7,["<char1>"],"A lateral follow shot tracks <Subject 1> through a corridor of white sheets, her silhouette appearing and disappearing as the cloth lifts.","Layered fabric movement and roof ambience."),
shot(8,["<char2>"],"Near the stair wall, <Subject 1> gathers three pillowcases against his chest and waits for a stronger gust to pass.","A gust rises and softens; no speech."),
shot(9,["<char1>","<char2>"],"The pair carry separate light bundles toward the sheltered wall, leaving the center route open as the remaining lines sway.","Measured steps and loose cloth."),
shot(10,["<char2>"],"<Subject 1> sits briefly on the low stair step, then rises when the hanging sheets settle into a gentler rhythm.","Cardigan fabric, wind, and a distant city hum."),
shot(11,["<char1>"],"<Subject 1> lifts her empty wicker basket and turns toward the far laundry row, where blue shadow moves behind two sheets.","Basket handle and fabric in wind."),
shot(12,["<char3>"],"A medium shot reveals <Subject 1> emerging between two billowing sheets with the same empty blue basket, first as a shadow and then fully visible in his sand overshirt.","The terrace door is now quiet and the same neighbor speaks.",[line("<char3>","The latch is holding now. The remaining lines are sheltered enough to finish slowly.")])
]
},
{
"case_id": "worker_09_tier2", "tier": 2, "target_identity": "<char3>",
"first_appearance_shot": 6, "reappearance_shot": 14, "absence_gap": 7,
"characters": {
"<char1>": "a young East Asian woman with a short auburn bob, a white baker jacket, dark trousers, and heatproof gray mitts",
"<char2>": "a middle-aged Black man with a shaved head, a brown delivery coat, black trousers, and both hands on an empty steel cart",
"<char3>": "an older Latina woman with silver hair under a blue scarf, a cream baker jacket, navy trousers, and a dark green apron"
},
"shot_specs": [
shot(1,["<char1>"],"In a bakery back kitchen, <Subject 1> opens the walk-in oven and steps aside as warm steam rolls into the clear central passage.","Oven fans, a door hinge, and one voice.",[line("<char1>","The first loaves are ready. I will let the steam clear before moving them.")]),
shot(2,["<char2>"],"At the street delivery door, <Subject 1> rolls an empty steel cart over the threshold and stops before entering the warm kitchen.","Cart wheels, morning street noise, and one voice.",[line("<char2>","I will wait here until the oven path is open.")]),
shot(3,["<char1>"],"<Subject 1> backs one loaded rack slowly out of the oven and turns it into the cooling passage without touching the work counters.","Rack wheels and fading oven fans."),
shot(4,["<char2>"],"<Subject 1> pushes the empty cart along the marked wall route, then yields as the hot rack crosses ahead.","Steel wheels and room ventilation."),
shot(5,["<char1>","<char2>"],"A wide kitchen view shows <Subject 1> guide the hot rack toward the cooling zone while <Subject 2> keeps the delivery cart near the wall.","Two wheel rhythms and light steam."),
shot(6,["<char3>","<char1>","<char2>"],"<Subject 1> enters from the cool-room passage, observes the crossing routes, then heads toward the street door after speaking.","Ventilation, wheels, and one experienced voice.",[line("<char3>","Keep the center clear. I will open the street door fully and guide the empty cart in.")]),
shot(7,["<char1>"],"<Subject 1> walks beside the cooling rack and checks the spacing by looking down the passage, not by rearranging small items.","Cooling fans and soft footsteps."),
shot(8,["<char2>"],"<Subject 1> rolls the empty cart one doorway farther, then stops as another wave of steam crosses the route.","Cart brakes and oven air."),
shot(9,["<char1>","<char2>"],"The two exchange positions around the wide passage: <Subject 1> moves the rack forward while <Subject 2> backs the empty cart into a recess.","Wheels, floor seams, and no speech."),
shot(10,["<char1>"],"<Subject 1> opens a high vent window and steps back as the steam thins toward the ceiling.","A window latch and rising ventilation."),
shot(11,["<char2>"],"<Subject 1> looks through the open delivery doorway, then turns the cart so its narrow end faces the kitchen route.","Street rain, cart casters, and one short remark.",[line("<char2>","The doorway is wide enough now. I can bring it through without crossing the hot rack.")]),
shot(12,["<char1>","<char2>"],"<Subject 1> walks ahead of the cooling rack while <Subject 2> advances the empty cart along the opposite wall, both at a slow pace.","Parallel wheel sounds and fans."),
shot(13,["<char1>"],"At the far end of the cooling passage, <Subject 1> stops the rack and turns toward movement between the tall cooling frames.","A brake clicks and the kitchen settles."),
shot(14,["<char3>"],"<Subject 1> walks into view between the cooling frames beside the now-open route, clearly matching the blue scarf, green apron, and cream jacket seen earlier.","Street air enters and the same baker speaks.",[line("<char3>","The entrance is secure and the route is clear. Bring the empty cart along the wall.")]),
shot(15,["<char1>","<char2>","<char3>"],"<Subject 3> guides the empty cart into the cooling area while <Subject 1> holds the hot rack stationary and <Subject 2> walks beside his cart.","Wheels move through the open kitchen; no dialogue.")
]
},
{
"case_id": "worker_10_tier2", "tier": 2, "target_identity": "<char3>",
"first_appearance_shot": 6, "reappearance_shot": 15, "absence_gap": 8,
"characters": {
"<char1>": "an older Black man with a close gray beard, a burgundy flat cap, a camel coat, and a walnut walking stick",
"<char2>": "a young white woman with shoulder-length blond hair, a cobalt rain jacket, black trousers, and a canvas tote",
"<char3>": "a middle-aged South Asian nonbinary transit volunteer with short salt-and-pepper curls, a teal vest over a gray shirt, and a small circular badge"
},
"shot_specs": [
shot(1,["<char1>"],"Inside a moving tram, <Subject 1> rises from a rear seat and grips the vertical rail as shopfronts slide past the window.","Rail hum, wheel rhythm, and one voice.",[line("<char1>","My stop has a low platform. I will move closer to the center door before we arrive.")]),
shot(2,["<char2>"],"<Subject 1> stands from the facing seat and moves her tote behind her leg, clearing the aisle toward the articulated connection.","Tram joints creak and one reply.",[line("<char2>","The aisle is clear. I can hold this rail while you pass.")]),
shot(3,["<char1>","<char2>"],"<Subject 1> walks toward the connection with his stick close to his side while <Subject 2> steps into the vacated window space.","Measured steps and steady rail noise."),
shot(4,["<char1>"],"At the flexible connection, <Subject 1> waits through a gentle curve as the floor shifts beneath him, then continues when the tram straightens.","Joint bellows and wheel flange."),
shot(5,["<char2>","<char1>"],"<Subject 1> follows several paces behind <Subject 2> into the middle section; outside, commercial signs give way to brick apartments.","Tram hum and a distant stop bell."),
shot(6,["<char3>","<char1>","<char2>"],"<Subject 1> enters from the front section, greets both passengers, then prepares to step onto the approaching low platform with <Subject 2>.","Brakes engage and one calm volunteer speaks.",[line("<char3>","I will step down with you and point out the level path to the exit.")]),
shot(7,["<char2>"],"After the doors close, <Subject 1> takes a window seat in the middle section while the tram continues into a quieter residential street.","Doors seal and the motor rises."),
shot(8,["<char2>"],"<Subject 1> watches row houses pass and shifts her tote onto her lap as sunlight replaces the earlier rain reflections.","Wheel rhythm and soft cabin ventilation."),
shot(9,["<char2>"],"At the next curve, <Subject 1> stands and moves one pole forward, leaving the doorway zone open for boarding passengers outside the frame.","A turn signal chime and track noise."),
shot(10,["<char2>"],"A long interior view follows <Subject 1> through the articulated joint as trees begin to fill the windows beyond her.","Bellows creak and restrained footsteps."),
shot(11,["<char2>"],"<Subject 1> sits near the rear door and looks at the raised platform sliding alongside, comparing it with the lower stop already passed.","Platform ambience and soft brakes."),
shot(12,["<char2>"],"The tram departs again; <Subject 1> remains by the window while residential blocks alternate with small gardens.","Motor acceleration and wheel rhythm."),
shot(13,["<char2>"],"<Subject 1> crosses to the opposite seat as afternoon light moves from one side of the cabin to the other.","Seat fabric and a quiet carriage."),
shot(14,["<char2>"],"At another stop, <Subject 1> looks toward the rear door as it opens onto a tree-lined platform and a familiar teal color approaches from outside.","Door chime, birds outside, and idling tram noise."),
shot(15,["<char3>"],"<Subject 1> boards through the rear door at the new stop, the same teal vest, gray shirt, circular badge, and salt-and-pepper curls clearly visible against the residential street.","Doors remain open briefly and the same volunteer speaks.",[line("<char3>","The level path was open, and I caught the next tram here as planned.")])
]
}
]
def main():
cases = [compile_case(case) for case in CASES]
OUT.parent.mkdir(parents=True, exist_ok=True)
OUT.write_text(json.dumps(cases, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
print(json.dumps({"cases": len(cases), "shots": sum(len(c["shots"]) for c in cases), "output": str(OUT)}, indent=2))
if __name__ == "__main__":
main()