Skip to content

Commit 5cc7e27

Browse files
Randomname653claude
andcommitted
The dialogue line must quote the runtime it was measured against
First real scan put the feature in front of actual proposals and showed the numbers disagreeing with each other: 'Sakura Wars — 69 words/min, 2 of 115 min without dialogue'. The rate was right (computed against one episode) but the 115 minutes is the SERIES total from MediaTechProfile, so an episode's silence was rendered against a season's length. The measured runtime is now stored alongside the metrics and read back from there, with a migration for installs that already have the table. The track's language tag is also no longer printed unless it is a plain code — this library has a track labelled Hindi holding no Devanagari and one labelled German that was Thai, and a wrong label on an evidence line is worse than no label. Also: the warm-up log line now reports dialogue profiles alongside articles and reception. The UI message already did; the logger did not, which made a working feature look like it had never run. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 0649c2d commit 5cc7e27

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

src/database/connection.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ def _migrate_columns() -> None:
7878
"""Add columns introduced after initial schema creation (SQLite-safe)."""
7979
from sqlalchemy import text
8080
new_cols = [
81+
# Subtitle metrics: the episode runtime they were measured against
82+
# (MediaTechProfile holds the SERIES total, which is a different number)
83+
("media_subtitle_profiles", "duration_min", "FLOAT"),
8184
("deletion_proposals", "category", "TEXT"),
8285
("deletion_proposals", "poster_url", "TEXT"),
8386
("deletion_proposals", "synopsis", "TEXT"),

src/database/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,11 @@ class MediaSubtitleProfile(Base):
687687
mattr = Column(Float, nullable=True) # NOT raw TTR (length-biased)
688688
total_words = Column(Integer, nullable=True)
689689
coverage = Column(Float, nullable=True) # cue span / runtime
690+
# The runtime these figures were computed against. For a series that is ONE
691+
# episode, never the season total — MediaTechProfile aggregates every
692+
# episode, and rendering "2 of 115 min without dialogue" from an episode's
693+
# silence and a season's length reads as nonsense.
694+
duration_min = Column(Float, nullable=True)
690695
checked = Column(Boolean, default=False)
691696
metrics_v = Column(String(16), nullable=True)
692697
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)

src/services/recommendations_engine.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,8 +1750,10 @@ def _cmp_vec(vec):
17501750
f"{_warmed_rec} reception, {_warmed_wd} on-record facts, "
17511751
f"{_warmed_sub} dialogue profiles")
17521752
logger.info("[deletions] %s: pre-judge warm-up added %d article(s), "
1753-
"%d reception record(s), %d wikidata record(s)",
1754-
category, _warmed, _warmed_rec, _warmed_wd)
1753+
"%d reception record(s), %d wikidata record(s), "
1754+
"%d dialogue profile(s)",
1755+
category, _warmed, _warmed_rec, _warmed_wd,
1756+
_warmed_sub)
17551757
except Exception as _e:
17561758
logger.debug("[deletions] pre-judge warm-up failed: %s", _e)
17571759
_gate_label = f"deletion scan: {category}"

src/services/subtitle_signals.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,11 @@ def format_dialogue_line(m: dict, lang: str = "") -> str:
431431
"""
432432
if not m or not m.get("words_per_min"):
433433
return ""
434-
lang_part = f"{lang} " if lang else ""
434+
# The track's own language tag is demonstrably unreliable here (a track
435+
# labelled Hindi contained no Devanagari; one labelled German was Thai),
436+
# so it is only shown when the metrics were computed at all — and never
437+
# presented as a fact about the work.
438+
lang_part = f"{lang} " if lang and len(lang) <= 5 else ""
435439
sdh = ", SDH track" if m.get("is_sdh") else ""
436440
div = (f", lexical diversity {m['mattr']}" if m.get("mattr") is not None
437441
else "")
@@ -580,6 +584,7 @@ async def topup_subtitle_metrics(title: str, media_type: str, *,
580584
row.mattr = m.get("mattr")
581585
row.total_words = m.get("total_words")
582586
row.coverage = m.get("coverage")
587+
row.duration_min = m.get("duration_min")
583588
db.commit()
584589
return bool(m)
585590
except Exception as e:
@@ -610,7 +615,9 @@ def subtitle_facts(item: dict, media_type: str) -> str:
610615
return format_dialogue_line({
611616
"words_per_min": row.words_per_min,
612617
"silent_min": row.silent_min or 0.0,
613-
"duration_min": dur or 0.0,
618+
# The runtime we MEASURED against — for a series one episode,
619+
# not the season total the tech profile carries.
620+
"duration_min": row.duration_min or dur or 0.0,
614621
"mattr": row.mattr,
615622
"is_sdh": bool(row.is_sdh),
616623
}, lang=row.language or "")

0 commit comments

Comments
 (0)