Stage D trial 3 (fresh sample, per-channel, regression samples) and Director's Desk read-only design
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Director's Desk, read-only design (Stage D phase 4, 4 November 2026). One TV screen, Orbit's navy and gold, built from the
|
||||
second trial's real numbers. A design proposal only: nothing in the app, no decisions from it."""
|
||||
from pathlib import Path
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
HERE = Path(__file__).resolve().parent
|
||||
F = HERE.parent / 'channels' / 'network-fonts'
|
||||
def font(name, size): return ImageFont.truetype(str(F / name), size)
|
||||
W, H = 1920, 1080
|
||||
NAVY, DEEP, PANEL, GOLD, WHITE, MUTED, MINT, SKY = (7, 22, 50), (4, 13, 32), (16, 40, 84), (242, 193, 78), (255, 255, 255), (160, 178, 206), (110, 220, 170), (120, 190, 255)
|
||||
im = Image.new('RGB', (W, H), DEEP); d = ImageDraw.Draw(im)
|
||||
anton, semi, reg, cond = (lambda s: font('anton-regular.ttf', s)), (lambda s: font('barlow-semibold.ttf', s)), (lambda s: font('barlow-regular.ttf', s)), (lambda s: font('barlow-condensed-medium.ttf', s))
|
||||
def box(x, y, w, h, fill=PANEL, r=14, outline=None): d.rounded_rectangle((x, y, x + w, y + h), r, fill=fill, outline=outline, width=3 if outline else 0)
|
||||
# Header
|
||||
d.text((80, 56), "DIRECTOR'S DESK", font=anton(64), fill=GOLD)
|
||||
d.text((84, 140), 'This week on Orbit · Wednesday 4 November', font=reg(30), fill=MUTED)
|
||||
x = 1180
|
||||
for label, on in (('FAMILIAR', False), ('BALANCED', True), ('SURPRISE ME', False)):
|
||||
w = d.textlength(label, font=semi(26)) + 40
|
||||
box(x, 70, w, 52, fill=GOLD if on else PANEL, r=26); d.text((x + 20, 80), label, font=semi(26), fill=DEEP if on else WHITE); x += w + 14
|
||||
d.text((1180, 136), 'Auto-approval: OFF', font=semi(24), fill=MINT)
|
||||
# This week: routine matches as counts
|
||||
box(80, 200, 520, 700)
|
||||
d.text((112, 226), 'THIS WEEK', font=anton(34), fill=WHITE)
|
||||
d.text((112, 280), '392', font=anton(72), fill=GOLD); d.text((260, 304), 'new to the library', font=reg(30), fill=WHITE)
|
||||
d.text((112, 380), '38', font=anton(56), fill=MINT); d.text((210, 396), 'routine matches, 11 channels', font=reg(28), fill=WHITE)
|
||||
rows = [('Ring X', 10), ('Dark Files', 7), ('Vortex', 6), ('Evidence', 4), ('Orbit Horror', 4), ('Odyssey', 2), ('+5 more', 5)]
|
||||
y = 470
|
||||
for name, n in rows:
|
||||
d.text((112, y), name, font=reg(26), fill=MUTED); d.rounded_rectangle((330, y + 8, 330 + n * 22, y + 26), 6, fill=SKY); d.text((340 + n * 22, y), str(n), font=semi(26), fill=WHITE); y += 44
|
||||
d.text((112, 800), 'Held as Proposed, not booked.', font=reg(24), fill=MUTED); d.text((112, 834), 'OK to look through them.', font=reg(24), fill=MUTED)
|
||||
# Worth a look: 3 to 5 discoveries
|
||||
d.text((640, 210), 'WORTH A LOOK', font=anton(34), fill=WHITE)
|
||||
picks = [('PREMIERE', 'Blue Planet III', 'Terra', 'David Attenborough returns to the oceans; new 31 October'),
|
||||
('STRONG MATCH', 'The Fit Bit Killer', 'Dark Files', 'True crime: a murder in Athens, and the questions after'),
|
||||
('STRONG MATCH', 'Dustfall', 'Evidence', 'A detective returns home to a dangerous investigation'),
|
||||
('NEW ANIME', 'A Tale of the Secret Saint', 'Vortex', 'A would-be knight awakens as a legendary saint')]
|
||||
y = 260
|
||||
for tag, title, ch, why in picks:
|
||||
focus = title == 'Blue Planet III'
|
||||
box(640, y, 640, 146, fill=(28, 58, 112) if focus else PANEL, outline=GOLD if focus else None)
|
||||
d.text((668, y + 16), tag, font=semi(22), fill=GOLD); d.text((668, y + 44), title, font=semi(36), fill=WHITE)
|
||||
d.text((668, y + 94), why, font=reg(24), fill=MUTED); d.text((1150, y + 18), ch.upper(), font=semi(22), fill=SKY)
|
||||
y += 160
|
||||
# Needs your eye: genuine decisions
|
||||
d.text((1320, 210), 'NEEDS YOUR EYE', font=anton(34), fill=WHITE)
|
||||
asks = [('Africa: Earth’s Wild Home', 'Terra or Odyssey?'), ('Wicker', 'BritX or Orbit Romance?'), ('Mum, I’m Alien Pregnant', 'Sci-Fi or Horror?')]
|
||||
y = 260
|
||||
for title, q in asks:
|
||||
box(1320, y, 520, 120); d.text((1348, y + 18), title, font=semi(30), fill=WHITE); d.text((1348, y + 66), q, font=reg(26), fill=GOLD); y += 136
|
||||
d.text((1320, 680), 'RECENTLY DECIDED', font=anton(30), fill=WHITE)
|
||||
for k, line in enumerate(('Made-for-TV romances: not for Orbit', 'Tales from the Crypt: After Dark strand', 'Black Mirror: Paradox from 21:00')):
|
||||
d.text((1320, 730 + k * 44), '· ' + line, font=reg(26), fill=MUTED)
|
||||
# Footer
|
||||
d.text((80, 990), 'OK open LEFT / RIGHT move BACK home', font=cond(28), fill=MUTED)
|
||||
d.text((1080, 990), 'Read-only preview: nothing is booked or changed from this screen', font=cond(28), fill=MUTED)
|
||||
im.save(HERE / 'directors-desk-v1.png')
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 170 KiB |
@@ -0,0 +1,15 @@
|
||||
import json,sys,collections
|
||||
S=sys.argv[1]; V={o['id']:o for o in json.load(open(f'{S}/{sys.argv[2]}'))}
|
||||
def ev(L,th):
|
||||
must=[i for i in L if L[i] and '' not in L[i]]; none=[i for i in L if not L[i]]
|
||||
sug=[i for i in L if V[i]['s1']>=th and V[i]['s2']<V[i]['s1']*.85]
|
||||
right=[i for i in sug if V[i]['top'] in L[i]]
|
||||
found=[i for i in must if i in sug and V[i]['top'] in L[i]]
|
||||
fp=[i for i in none if i in sug]
|
||||
wrong=[i for i in sug if V[i]['top'] not in L[i]]
|
||||
return dict(n=len(L),sug=len(sug),prec=len(right)/max(1,len(sug)),recall=f"{len(found)}/{len(must)}",fp=f"{len(fp)}/{len(none)}",wrong=[(V[i]['title'][:30],V[i]['top']) for i in wrong],missed=[(V[i]['title'][:30],L[i][0] if L[i] else '',V[i]['top'],V[i]['s1']) for i in must if i not in found])
|
||||
for f in sys.argv[3:]:
|
||||
L=json.load(open(f'{S}/{f}'))
|
||||
for th in (.45,.35):
|
||||
r=ev(L,th); print(f,th,'suggested',r['sug'],'precision',f"{r['prec']:.0%}",'recall',r['recall'],'false placements on no-home',r['fp']); print(' wrong',r['wrong']);
|
||||
if th==.35: print(' missed',r['missed'])
|
||||
@@ -0,0 +1 @@
|
||||
{"8009312": [], "8078448": ["Dark Files"], "7998858": [], "8002849": [], "7982220": ["Orbit Romance"], "8060672": [], "8005900": [], "7981213": ["Dark Files"], "8063723": ["Orbit Horror", "After Dark"], "8036706": [], "8063799": ["Orbit Romance", "BritX"], "8065673": [], "8070609": [], "8056325": [], "8065631": ["", "Orbit Premiere"], "8054668": [], "7993465": [], "8002696": [], "7999478": ["", "PixelZ"], "7998882": [], "8014652": ["", "Orbit 2"], "7991575": ["Orbit Romance"], "8057254": ["Ring X"], "8002507": [], "8008372": [], "8067827": [], "8068916": [], "8064652": [], "8000477": ["Orbit Action"], "8003324": [], "7978360": [], "7988199": ["Evidence"], "8059718": [], "8068177": [], "8068803": ["", "Orbit Action"], "8001802": [], "8067524": [], "8020593": ["Orbit Horror"], "8001326": ["", "Orbit 1"], "7980720": [], "8065517": [], "8055642": ["BritX"], "7998439": ["Orbit Horror", "After Dark"], "8006374": [], "8064561": [], "7991863": [], "8019916": [], "8059814": ["Orbit Romance"], "7998500": [], "8059092": ["", "Orbit Three", "Orbit 1"], "8068802": [], "7980716": ["Ring X"], "8069094": [], "7986681": [], "7993234": [], "8007968": ["Vortex"], "8006205": ["", "Vortex"], "8015874": [], "7999723": [], "8068581": ["Dark Files"]}
|
||||
@@ -0,0 +1 @@
|
||||
{"8061719":[],"7990654":[],"8014514":["Vortex",""],"8018748":[],"8054652":["","Orbit Premiere"],"8014763":["Dark Files"],"7998267":[],"8076383":["Dark Files"],"8002269":[],"8000996":["","Orbit Action","Orbit Premiere"],"8064403":["","Orbit 2","Orbit Three"],"8058519":["","Orbit Action"],"8014850":[],"8015663":[""],"8018840":["Vortex"],"8002646":["Evidence"],"8068419":[],"7985411":["Vortex"],"8020592":["Orbit Horror","After Dark"],"8008678":[],"7993183":[],"8014260":["Orbit Horror","After Dark"],"8005458":["","Vortex"],"8062525":[],"7985729":["Riot"],"8017065":["Orbit Horror","After Dark"],"7983711":["Dark Files"],"7999018":["","Orbit Action"],"7980339":[],"8001615":[],"7988590":["","Riot","Vortex"],"8020625":["Paradox",""],"8014564":[],"8005767":["Orbit Three","Paradox",""],"8016391":[],"7986603":[],"8068826":["After Dark","Orbit Horror",""],"7998219":[],"8059189":[],"8059883":[],"8001772":[],"8070303":[],"8057986":["Paradox"],"8005522":["","Riot","Vortex"],"8066994":["Orbit Horror","After Dark"],"8000537":["Evidence"],"8059669":["","Rewind","Vortex"],"8059757":[],"8070341":["Terra"],"7996078":[],"7986970":["","Odyssey"],"8059396":[],"8017361":[],"8008734":["Evidence"],"7995268":["Orbit Action"],"8059121":[],"8001610":[],"7989166":[],"8019148":["Paradox"],"8018213":["Orbit Romance","Orbit Premiere",""]}
|
||||
@@ -0,0 +1 @@
|
||||
{"7997934":[],"7990343":[],"7997920":[],"8004097":[],"8006222":["","Vortex"],"8059706":[],"7992286":["","Orbit 2","Orbit Wild"],"8063802":[],"8059688":[],"8070401":[],"8078255":["Orbit Action"],"8060602":[],"7984233":["Orbit Action"],"8069326":[],"8004110":[],"8057270":["","Orbit Three","Paradox"],"8003572":[],"7992309":[],"7993894":["","Orbit 1","Orbit Three"],"8015209":[],"8020676":["Orbit Horror","After Dark"],"8001473":[],"8003473":["","Paradox","Orbit Junior"],"7997175":[],"7983690":[],"8064662":["","Orbit 1"],"8018565":["","Ring X","Dark Files"],"8053190":[],"8057209":[],"7988409":["","Orbit Action"],"8063800":["Orbit Horror","Orbit Premiere","Orbit Sci-Fi","After Dark"],"7998091":["","Evidence"],"8053589":[],"8019919":[],"7984422":[],"8001782":["Evidence"],"8064648":[],"7918893":[],"8036553":[],"8014136":["","Vortex"],"8069389":[],"8014328":["","Orbit Premiere","Orbit Action","Detour"],"8016310":[],"7997957":[],"8005689":["","Vortex"],"7985721":[],"8014863":["After Dark","Orbit Horror"],"8000540":[],"7999979":["Ring X"],"8014370":[],"8057745":[],"8000875":[],"7895642":[],"8059925":["Evidence"],"7986731":["","Evidence"],"8054463":[],"7997680":[],"8055180":[],"8063988":[],"8036794":[]}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,155 @@
|
||||
import json,re,math,collections,sys,glob,sqlite3
|
||||
S,R=sys.argv[1],sys.argv[2]
|
||||
ev={}
|
||||
for l in open(f'{S}/evidence-0.jsonl'):
|
||||
r=json.loads(l); ev[r['id']]=r
|
||||
c=sqlite3.connect(f'file:{S}/cat-now/catalogue.db?mode=ro',uri=True)
|
||||
UK=re.compile(r'United Kingdom|England|Scotland|Wales|\bUK\b')
|
||||
UKSTUDIO=re.compile(r'\bBBC\b|\bITV\b|Channel 4|Film4|Sky\b|Working Title|Ealing|Hammer|Aardman',re.I)
|
||||
def W(*words): return re.compile(r'\b('+'|'.join(words)+r')',re.I)
|
||||
# Each channel's brief from docs/channels and Paul's 4 November definitions: what it carries, themes for and against, era, ratings, origin.
|
||||
B={
|
||||
'101':dict(name='Orbit 1',kind={'Series'},genres_any={'Comedy'},themes=W('sitcom','family','friends','comedy'),against=W('murder','killer','documentary'),era=(1970,2026),kids=False),
|
||||
'102':dict(name='Orbit 2',kind={'Series'},genres_any={'Game Show','Reality','Comedy','Talk'},themes=W('quiz','game show','contestants','panel','challenge','teams compete'),against=W('murder','documentary'),era=(1960,2015),kids=False,uk=True),
|
||||
'103':dict(name='Orbit Three',kind={'Series'},genres_any={'Comedy'},themes=W('sketch','cult comedy','surreal','dark comedy','scottish'),against=W('documentary'),era=(1990,2026),kids=False,uk=True),
|
||||
'104':dict(name='Orbit Gold',kind={'Series'},genres_any={'Comedy'},themes=W('sitcom','classic comedy'),against=W('documentary'),era=(1960,1999),kids=False,uk=True),
|
||||
'105':dict(name='Riot',kind={'Series'},genres_any={'Animation','Comedy'},need_any={'Animation'},themes=W('adult','irreverent','raunchy','satir','dysfunctional'),against=W('preschool','children learn'),era=(1988,2026),kids=False),
|
||||
'106':dict(name='Paradox',kind={'Series'},genres_any={'Science Fiction','Fantasy','Mystery','Horror'},themes=W('supernatural','paranormal','alien','time travel','parallel','ghost','vampire','demon','monster','mysterious','strange','unexplained','dimension','future','space','dystopia','cult','prophecy','witch'),against=W('documentary','reality','romance','cooking'),era=(1955,2026),kids=False),
|
||||
'107':dict(name='Evidence',kind={'Series'},genres_any={'Crime','Mystery'},themes=W('detective','inspector','police','forensic','investigat','murder','homicide','case','sergeant','DCI','sleuth'),against=W('documentary','true story of','real-life','archive footage','interviews'),era=(1965,2026),kids=False,scripted=True),
|
||||
'201':dict(name='Terra',kind={'Series'},genres_any={'Documentary'},themes=W('wildlife','animal','ocean','sea','reef','planet','nature','ecosystem','species','forest','jungle','predator','habitat','natural world','migration'),against=W('murder','killer','crime','war','music','celebrity','royal','politic','AI','robot','superhero'),era=(1975,2026),kids=False,need_theme=True),
|
||||
'202':dict(name='Odyssey',kind={'Series'},genres_any={'Documentary','History'},themes=W('space','universe','astronom','science','engineer','scientist','history','ancient','explor','discover','technolog','travel','civilisation','civilization'),against=W('murder','killer','crime','celebrity','reality'),era=(1950,2026),kids=False),
|
||||
'203':dict(name='Orbit Wild',kind={'Series'},genres_any={'Reality','Documentary','Adventure'},themes=W('surviv','wilderness','expedition','endurance','extreme','remote','frontier','adventure','island','alone','hunt','fishing'),against=W('murder','dating','cooking','makeover'),era=(1985,2026),kids=False,need_theme=True),
|
||||
'204':dict(name='Dark Files',kind={'Series'},genres_any={'Documentary','Crime','Mystery'},need_any={'Documentary'},themes=W('murder','killer','disappear','missing','true crime','unsolved','investigat','case','paranormal','haunt','unexplained','cult','conspiracy','serial','detective','victim','trial'),against=W('wildlife','cooking'),era=(1975,2026),kids=False,need_theme=True),
|
||||
'301':dict(name='Orbit Premiere',kind={'Movie'},genres_any={'Action','Adventure','Science Fiction','Fantasy'},themes=W('epic','hero','battle','world','mission','superhero','franchise'),against=W('documentary','concert'),era=(1975,2026),kids=False,current=True),
|
||||
'302':dict(name='Orbit Action',kind={'Movie'},genres_any={'Action'},themes=W('cop','agent','assassin','heist','fight','mercenar','revenge','martial','spy','chase','soldier'),against=W('documentary','concert','UFC','WWE'),era=(1960,2026),kids=False,current=True),
|
||||
'303':dict(name='Orbit Sci-Fi',kind={'Movie'},genres_any={'Science Fiction'},need_any={'Science Fiction'},themes=W('alien','space','future','robot','planet','time','dystopia','android','galaxy'),against=W('documentary'),era=(1950,2026),kids=False,current=True),
|
||||
'304':dict(name='Orbit Horror',kind={'Movie'},genres_any={'Horror'},need_any={'Horror'},themes=W('haunt','demon','possess','killer','evil','terror','ghost','curse','slasher','nightmare'),against=W('documentary'),era=(1960,2026),kids=False,current=True),
|
||||
'305':dict(name='After Dark',kind={'Movie'},genres_any={'Horror','Thriller','Science Fiction'},themes=W('cult','bizarre','strange','exploitation','b-movie','grindhouse','creature','mutant','zombie','cannibal','obscure','surreal','underground'),against=W('documentary','romcom','family'),era=(1955,2018),kids=False,intl_bonus=True),
|
||||
'306':dict(name='Orbit VHS',kind={'Movie'},genres_any={'Comedy','Adventure','Fantasy','Family','Science Fiction'},themes=W('kids','teen','adventure','summer','gang','treasure'),against=W('documentary'),era=(1980,1995),kids=False),
|
||||
'307':dict(name='Orbit Romance',kind={'Movie'},genres_any={'Romance'},need_any={'Romance'},themes=W('love','romance','falls for','wedding','relationship','heart'),against=W('documentary','murder','horror'),era=(1930,2026),kids=False,current=True),
|
||||
'308':dict(name='Detour',kind={'Movie'},genres_any={'Comedy'},need_any={'Comedy'},themes=W('road trip','party','college','bachelor','friends','wild night','spring break'),against=W('documentary','animated'),era=(1990,2026),kids=False,current=True,need_theme=True),
|
||||
'309':dict(name='BritX',kind={'Movie'},genres_any={'Crime','Comedy','Drama','Thriller'},themes=W('gangster','gang','criminal','crime','heist','drug','hooligan','council estate','thug','con','robbery','dealer'),need_theme=True,against=W('documentary'),era=(1965,2026),kids=False,uk=True,current=True),
|
||||
'401':dict(name='Ring X',kind={'Movie','Series'},genres_any={'Sport','Action','Documentary'},themes=W('wrestl','WWE','AEW','TNA','UFC','MMA','mixed martial','title match','pay-per-view','bout'),against=W('romance'),era=(1980,2026),kids=False,current=True,need_theme=True),
|
||||
'601':dict(name='Vortex',kind={'Series','Movie'},genres_any={'Animation','Action','Anime'},need_any={'Animation','Anime'},themes=W('anime','fight','power','warrior','battle','hero','martial','saiyan','ninja','mecha','demon'),against=W('preschool','sitcom'),era=(1980,2026),kids=False,need_theme=True),
|
||||
'602':dict(name='Heroes',kind={'Series'},genres_any={'Animation','Action'},need_any={'Animation'},themes=W('superhero','batman','spider','x-men','justice','villain','powers'),against=W('preschool'),era=(1980,2015),kids=True),
|
||||
'603':dict(name='Orbit X',kind={'Series'},genres_any={'Animation','Action','Adventure'},need_any={'Animation','Children','Family'},themes=W('rangers','robot','team','evil','power','adventure','toy'),against=W('preschool','adult'),era=(1980,2002),kids=True),
|
||||
'604':dict(name='Rewind',kind={'Series'},genres_any={'Animation','Comedy'},need_any={'Animation'},themes=W('cartoon','kids','adventures','friends'),against=W('adult','preschool'),era=(1990,2015),kids=True),
|
||||
'605':dict(name='ToonZ',kind={'Series'},genres_any={'Animation','Comedy'},need_any={'Animation'},themes=W('cartoon','classic'),against=W('adult'),era=(1928,2005),kids=True),
|
||||
'611':dict(name='Orbit Junior',kind={'Series'},genres_any={'Children','Family','Animation','Comedy'},need_any={'Children','Kids','Family'},themes=W('children','kids','school','friends','adventure'),against=W('adult','murder'),era=(1955,2026),kids=True,uk=True),
|
||||
'612':dict(name='Wonder',kind={'Movie'},genres_any={'Animation','Family','Fantasy'},need_any={'Animation'},themes=W('princess','magic','fairy','kingdom','adventure','tale'),against=W('adult','horror','preschool','junior','Disney Jr','Spidey'),era=(1935,2026),kids=True),
|
||||
'613':dict(name='PixelZ',kind={'Movie'},genres_any={'Animation','Family','Comedy'},need_any={'Animation'},themes=W('adventure','friends','family','toy','journey'),against=W('adult','horror'),era=(1995,2026),kids=True,current=True),
|
||||
'614':dict(name='Tots',kind={'Series'},genres_any={'Children','Animation','Family'},need_any={'Children','Kids'},themes=W('preschool','little','learn','friends','gentle','toddler','young children'),against=W('adult','violence','fight','battle'),era=(1980,2026),kids=True),
|
||||
}
|
||||
KIDS_OK={'G','PG','TV-Y','TV-Y7','TV-G','TV-PG','U','TV-Y7-FV','E','0+','3+','6+','7+'}
|
||||
ADULT={'R','TV-MA','NC-17','18','18+','X','NR18','SG-R21','SG-M18','GB-18'}
|
||||
SYN={'Anime':'Animation','Martial Arts':'Action','Sci-Fi & Fantasy':'Science Fiction','Action & Adventure':'Action','Kids':'Children','Suspense':'Thriller','Sports':'Sport'}
|
||||
def gen(r): return {SYN.get(g,g) for g in (r.get('genres') or [])}
|
||||
# Channel text profiles: TF-IDF of their titles' descriptions, so a candidate is also compared with what the channel actually shows.
|
||||
STOP=set('a an the and or of to in on for with his her their its is are was be by as at from this that he she they it into who when after one two new life series film show story world'.split())
|
||||
def toks(t): return [w for w in re.findall(r"[a-z][a-z'-]{2,}",(t or '').lower()) if w not in STOP]
|
||||
pools={}
|
||||
for f in glob.glob(f'{R}/episodes-*.json'):
|
||||
ch=f.split('-')[-1][:-5]
|
||||
if ch in B: pools[ch]=[s['id'] for s in json.load(open(f))['series']]
|
||||
docs={ch:[ev[i] for i in ids if i in ev and ev[i].get('overview')] for ch,ids in pools.items()}
|
||||
df=collections.Counter(w for ch in docs for d in docs[ch] for w in set(toks(d['overview'])))
|
||||
N=sum(len(v) for v in docs.values())
|
||||
def vec(text):
|
||||
tf=collections.Counter(toks(text)); return {w:(1+math.log(n))*math.log((N+1)/(df.get(w,0)+1)) for w,n in tf.items()}
|
||||
def norm(v):
|
||||
s=math.sqrt(sum(x*x for x in v.values())) or 1; return {k:x/s for k,x in v.items()}
|
||||
cent={}
|
||||
for ch,ds in docs.items():
|
||||
acc=collections.Counter()
|
||||
for d in ds:
|
||||
for k,x in norm(vec(d['overview'])).items(): acc[k]+=x
|
||||
cent[ch]=norm(dict(acc))
|
||||
def cos(a,b): return sum(x*b.get(k,0) for k,x in a.items())
|
||||
ENGLISH=re.compile(r'United States|United Kingdom|Canada|Australia|Ireland|New Zealand|England|Scotland|Wales')
|
||||
def original(i):
|
||||
row=c.execute('select original_title,title from items where id=?',(i,)).fetchone()
|
||||
return row or ('','')
|
||||
def foreign(r):
|
||||
o,t=original(r['id'])
|
||||
nonlatin=bool(re.search(r'[^\x00-\u024f\s\d\W]',o or ''))
|
||||
countries=' '.join(r.get('countries') or [])
|
||||
if nonlatin: return True,'original title not in English'
|
||||
if countries and not ENGLISH.search(countries): return True,'made in '+countries.split()[0]
|
||||
if o and t and o.strip().lower()!=t.strip().lower() and not re.search(r'[A-Za-z]{3}',o): return True,'original title differs'
|
||||
return False,''
|
||||
INTL={'305','601','401'}
|
||||
ANIMATED_CH={'105','601','602','603','604','605','611','612','613','614'}
|
||||
DOC_CH={'201','202','203','204','401'}
|
||||
FICTION_CH={'101','103','104','105','106','107','301','302','303','304','305','306','307','308','309','601','602','603','604','605','612','613'}
|
||||
LIVE=re.compile(r'\b(stand-up|standup|comedian|comedy special|unruly set|in this set|live from|in concert|tour film|takes aim at)\b',re.I)
|
||||
def score(r,ch):
|
||||
b=B[ch]; e=[]; typ=r.get('type'); g=gen(r); ov=r.get('overview') or ''; year=r.get('year'); rating=r.get('rating') or ''
|
||||
text=ov+' '+(r.get('name') or '')+' '+' '.join(r.get('taglines') or [])
|
||||
if typ not in b['kind']: return 0,['wrong kind']
|
||||
if b.get('kids') and rating in ADULT: return 0,[f'rated {rating}']
|
||||
s=0.
|
||||
# Format, as a hard limit: animation, documentary and fiction each have their own channels; live specials have none but Ring X's events.
|
||||
animated='Animation' in g
|
||||
doc=bool(g & {'Documentary'})
|
||||
if animated and ch not in ANIMATED_CH: return 0,['animation, not for this channel']
|
||||
if not animated and ch in ANIMATED_CH and g and ch not in ('611','601'): return 0,['live action, not for this channel']
|
||||
if doc and ch in FICTION_CH: return 0,['a documentary, not fiction']
|
||||
if g and not doc and ch in DOC_CH and ch!='401' and not (g & {'Reality'} and ch in ('203','204')): return 0,['fiction, not factual']
|
||||
if ch=='107' and (doc or g & {'Reality'}): return 0,['factual, and Evidence is scripted only']
|
||||
if LIVE.search(ov) and ch!='401': return 0,['a live or stand-up special']
|
||||
# Genres: only as one part of the evidence; missing genres are not held against it.
|
||||
if g:
|
||||
if b.get('need_any') and not (g & b['need_any']): return 0,[f'not {"/".join(sorted(b["need_any"]))}']
|
||||
gh=len(g & b['genres_any'])
|
||||
s+=.25*min(1,gh/1.5); e.append(f'genres {", ".join(sorted(g & b["genres_any"])) or "none of its"}')
|
||||
else: s+=.1; e.append('no genres given (not held against it)')
|
||||
# Themes from the description, for and against.
|
||||
pos=sorted(set(m.group(0).lower() for m in b['themes'].finditer(text)))
|
||||
neg=sorted(set(m.group(0).lower() for m in b['against'].finditer(text)))
|
||||
if ov:
|
||||
s+=.35*min(1,len(pos)/2); e.append(('themes: '+', '.join(pos[:4])) if pos else 'no brief themes in its description')
|
||||
if neg: s-=.25*min(1,len(neg)/2); e.append('against: '+', '.join(neg[:3]))
|
||||
sim=cos(norm(vec(ov)),cent.get(ch,{})) if ch in cent else 0
|
||||
short=len(ov)<200
|
||||
# A short description says little: lean on the defining genre and its themes instead of word similarity.
|
||||
if short and g and (g & (b.get('need_any') or b['genres_any'])) and (pos or b.get('need_any')): s+=.4*max(min(1,sim/.25),.6); e.append(f'short description, matched on genre ({sim:.2f})')
|
||||
else: s+=.4*min(1,sim/.25); e.append(f'description like its titles ({sim:.2f})')
|
||||
else: s+=.15; e.append('no description (not held against it)')
|
||||
if year:
|
||||
lo,hi=b['era']
|
||||
if year<lo-3 or year>hi+3: s*=.3 if not b.get('current') else 1; e.append(f'{year} outside its era {lo}-{hi}' if not b.get('current') else '')
|
||||
if b.get('uk'):
|
||||
uk=bool(UK.search(' '.join(r.get('countries') or []))) or bool(UKSTUDIO.search(' '.join(r.get('studios') or [])))
|
||||
if uk: s+=.1; e.append('British')
|
||||
elif r.get('countries') or r.get('studios'): s*=.6; e.append('not British by its studios or countries')
|
||||
if b.get('kids') and rating and rating not in KIDS_OK: s*=.5; e.append(f'rated {rating}')
|
||||
if b.get('kids') and not rating: s*=.8; e.append('no rating to confirm it suits children')
|
||||
if 'Horror' in g and ch in ('304','305') : s+=.12; e.append('a horror film')
|
||||
if 'Horror' in g and ch in ('308','307','612','613'): s*=.5; e.append('horror is not for this channel')
|
||||
if b.get('need_any') and g & b['need_any'] and len(ov)<160: s+=.1; e.append('short description, its defining genre carries more')
|
||||
if b.get('need_theme') and not pos: s*=.5; e.append('none of its themes')
|
||||
# Paul, 4 November 2026: made-for-TV romances (the Hallmark kind) aren't Orbit material.
|
||||
if 'TV Movie' in g: s*=.4; e.append('a made-for-TV film')
|
||||
f,why=foreign(r)
|
||||
if f and ch not in INTL: s*=.5; e.append(why+' (this channel is English-language)')
|
||||
return max(0,s),[x for x in e if x]
|
||||
def place(r):
|
||||
sc=sorted(((score(r,ch),ch) for ch in B),key=lambda x:-x[0][0])
|
||||
(s1,e1),c1=sc[0]; (s2,e2),c2=sc[1]
|
||||
if s1<.45: v='no clear home'
|
||||
elif s2>=s1*.85: v='ambiguous'
|
||||
else: v='suggested'
|
||||
tier='routine' if v=='suggested' and s1>=.7 and s2<s1*.7 else ('editorial' if v=='suggested' else ('needs evidence' if v=='ambiguous' else 'no action'))
|
||||
return dict(id=r['id'],title=r.get('name'),year=r.get('year'),type=r.get('type'),genres=sorted(gen(r)),verdict=v,tier=tier,top=B[c1]['name'],s1=round(s1,2),second=B[c2]['name'],s2=round(s2,2),evidence='; '.join(e1))
|
||||
if __name__=='__main__':
|
||||
ids=[row[0] for row in c.execute("select id from items where premiere between '2026-09-05' and '2026-11-04' and provider_ids like '%Imdb%'")]
|
||||
seen=set(); out=[]
|
||||
carried={i for v in pools.values() for i in v}
|
||||
for i in ids:
|
||||
if i not in ev or i in carried: continue
|
||||
r=ev[i]; key=(r.get('name'),r.get('year'))
|
||||
if key in seen: continue
|
||||
seen.add(key); out.append(place(r))
|
||||
json.dump(out,open(f'{S}/staged3.json','w'),indent=0,ensure_ascii=False)
|
||||
print(len(out),collections.Counter(o['verdict'] for o in out),collections.Counter(o['tier'] for o in out))
|
||||
print(collections.Counter(o['top'] for o in out if o['verdict']=='suggested').most_common())
|
||||
@@ -0,0 +1,89 @@
|
||||
# Stage D: trial 3 and the Director's Desk design (read only, 4 November 2026, 23:35)
|
||||
|
||||
Paul approved these at 23:27: Evidence for scripted procedurals only; Terra needing real nature evidence; stronger format distinctions; verified franchise matching; and better handling of short descriptions. Channel identity and age are hard limits.
|
||||
|
||||
Nothing is booked. No pool, schedule or committed booking changes. Auto-approval stays off. Script: `docs/replays/stage-d-trial-3.py`. Output: `docs/replays/stage-d-trial-3.json`.
|
||||
|
||||
## What changed in the scoring
|
||||
|
||||
- **Format as a hard limit:**
|
||||
- animation goes only to the animation channels (Riot, Vortex, Heroes, Orbit X, Rewind, ToonZ, Wonder, PixelZ, Tots, and Junior alongside live action);
|
||||
- documentaries never go to fiction channels;
|
||||
- fiction never goes to factual channels;
|
||||
- Evidence takes scripted procedurals only, so documentary and reality are ruled out;
|
||||
- stand-up and live specials go nowhere except Ring X's events.
|
||||
- **Themes required:** Terra, Dark Files, Ring X, Detour, Orbit Wild, BritX and Vortex each need their own themes in the description. Word similarity alone doesn't qualify. Dark Files also needs the Documentary genre.
|
||||
- **Short descriptions:** under 200 characters, a programme with the channel's defining genre and its themes is matched on those, instead of word similarity alone.
|
||||
- **Kept:** made-for-TV films are scored down (Paul's rule), foreign-language titles count against English-language channels, and the kids' rating rules stand.
|
||||
- **Franchises: no verified source yet.** The library's provider IDs carry TMDB, IMDb and TVDB IDs, but no collection or franchise links. There's no TMDB collection ID, and NCIS: New York isn't linked to NCIS. Matching titles by look-alike names isn't allowed, so franchise matching is **not active**. Two verified sources are possible:
|
||||
- **Emby's own collections (BoxSets),** read from your server like the evidence. This is local, read-only and fits the rules. It's the recommended next small read.
|
||||
- **Wikidata relationships.** This would mean lookups outside the box, so it's not proposed.
|
||||
|
||||
## Results
|
||||
|
||||
There are three hand-labelled samples of 60. The first two were used while tuning, so they're now **regression tests**. Sample 3 is fresh: drawn after the changes, labelled before scoring, and not tuned on. Each title is labelled with a channel, an acceptable alternative, or no home. The labels are my editorial judgement and are saved for Paul to check (`docs/replays/stage-d-regression-sample-*.json`). Run the evaluation with `stage-d-evaluate.py`.
|
||||
|
||||
| Sample | Model | Suggestions | Precision | Recall of clear fits | Titles with no home placed anyway |
|
||||
|---|---|---|---|---|---|
|
||||
| 1 (regression) | trial 3, routine | 14 | 100% | 12 of 16 | 0 of 37 |
|
||||
| 2 (regression) | trial 3, routine | 18 | 89% | 10 of 17 | 1 of 27 |
|
||||
| **3 (fresh)** | trial 1, genre only | 12 | 33% | 0 of 8 | 6 of 39 |
|
||||
| **3 (fresh)** | **trial 3, routine (≥ 0.45)** | 15 | **60%** | **4 of 8 (50%)** | **4 of 39** |
|
||||
| **3 (fresh)** | trial 3, routine plus editorial (≥ 0.35) | 19 | 63% | 5 of 8 | 5 of 39 |
|
||||
|
||||
**An honest reading:** on the fresh sample, trial 3 is much better than genre alone (60% against 33% precision, and 50% against 0% recall), but **well short of the 85 to 100% it scores on the samples it was tuned against**. That gap means the rules still fit the examples I've seen more than the library as a whole. Sample 3 also had many more titles with no home: 39 of 60.
|
||||
|
||||
**Failures on the fresh sample:**
|
||||
- **Odyssey took two non-science documentaries,** one about The Office and the Mike Tyson series. **Fix:** Odyssey needs its science, history or exploration themes, as Terra does.
|
||||
- **Foreign titles with no country recorded,** an Asian romcom series to Orbit 1 and an Indian crime series to Evidence. **Fix:** a rating from another country's board (the "SG-", "BR-" and "PL-" prefixes) counts as foreign-language evidence.
|
||||
- **The Mongoose went to Premiere rather than Orbit Action.** **Fix:** Premiere is for big event films; a mid-budget action film belongs on Action.
|
||||
- **A celebrity-villa reality show went to Orbit Wild.** **Fix:** Wild needs survival or expedition themes, not just Reality.
|
||||
- **A comedy-music film went to Detour.** **Fix:** Detour's themes need road trips and parties, not "friends".
|
||||
- **Missed horror** (The Influencer Project, Clayface) is held down by thin or unusual descriptions.
|
||||
|
||||
**Per channel, across all 180 labelled titles at the editorial line** (suggested / correct / clear fits in the samples):
|
||||
|
||||
| Channel | Suggested | Correct | Clear fits in the samples |
|
||||
|---|---|---|---|
|
||||
| Vortex | 9 | 9 | 3 |
|
||||
| Evidence | 8 | 6 | 6 |
|
||||
| Dark Files | 7 | 6 | 6 |
|
||||
| Orbit Horror | 6 | 6 | 9 |
|
||||
| Orbit Romance | 4 | 4 | 4 |
|
||||
| Orbit Action | 4 | 4 | 4 |
|
||||
| Ring X | 3 | 3 | 3 |
|
||||
| Paradox | 3 | 3 | 2 |
|
||||
| Orbit 1 | 2 | 1 | 0 |
|
||||
| Orbit Wild | 2 | 1 | 0 |
|
||||
| Odyssey | 2 | 0 | 0 |
|
||||
| BritX | 1 | 0 | 1 |
|
||||
| Riot | 1 | 1 | 1 |
|
||||
| Terra | 1 | 1 | 1 |
|
||||
| Premiere | 1 | 0 | 0 |
|
||||
| Detour | 1 | 0 | 0 |
|
||||
| After Dark | 0 | 0 | 1 |
|
||||
|
||||
**Reliable now:** Vortex, Orbit Horror, Romance, Action, Ring X, Paradox, Terra. **Need work:** Odyssey, Orbit Wild, Orbit 1, Detour, Premiere, BritX.
|
||||
|
||||
**What it means:** the Desk can show these as Proposed counts and picks, because Paul still decides everything. **Automatic approval is nowhere near ready.** It would need over 95% on fresh samples for a channel before it's even offered for that channel.
|
||||
|
||||
## The Director's Desk: read-only design (`design/directors-desk/directors-desk-v1.png`)
|
||||
|
||||
One TV screen, in Orbit's navy and gold, using the real numbers from this trial:
|
||||
- **This week:**
|
||||
- how many titles are new to the library (392);
|
||||
- the routine matches as **counts per channel** (38 across 11 channels), held as Proposed and never booked;
|
||||
- "OK to look through them" is optional.
|
||||
- **Worth a look:** three to five discoveries, each with a tag (Premiere, Strong match, New anime), the channel, and one line of evidence from its own description. In the mock-up: Blue Planet III for Terra, The Fit Bit Killer for Dark Files, Dustfall for Evidence, and A Tale of the Secret Saint for Vortex.
|
||||
- **Needs your eye:** only genuine either-or decisions, such as Africa: Earth's Wild Home (Terra or Odyssey?), Wicker (BritX or Romance?) and Mum, I'm Alien Pregnant (Sci-Fi or Horror?).
|
||||
- **Recently decided:** Paul's latest calls, so the director's learning is visible.
|
||||
- **Familiar, Balanced and Surprise Me** sit at the top, with Balanced the default. They set how many picks appear and how far from the familiar they reach. "Auto-approval: OFF" is always shown.
|
||||
- **Remote:** OK, left and right, Back. Nothing on this screen books or changes anything.
|
||||
|
||||
**Not yet designed or built, and waiting for Paul's approval of this read-only design:** the Approve, Not for Orbit and Later actions; the lifecycle states; and how an approval becomes a booking under each channel's policy.
|
||||
|
||||
## Proposed next steps
|
||||
|
||||
1. **The six fixes above,** then a fourth fresh sample, with samples 1 to 3 kept as regression tests.
|
||||
2. **A small read-only release** that reads Emby's own collections, so franchise matching can use verified links.
|
||||
3. **The Desk in the app, read-only,** exactly as designed, once Paul approves the design.
|
||||
Reference in New Issue
Block a user