sample-platform icon indicating copy to clipboard operation
sample-platform copied to clipboard

feat: smart (semantic) diff for subtitle regression outputs

Open gaurav02081 opened this issue 5 months ago • 2 comments

What this is

A semantic diff for regression-test outputs. Instead of a raw line diff, it classifies how two subtitle outputs differ, so a person — or an AI agent — gets an actionable verdict instead of a wall of changed lines.

Example: instead of "53 lines differ", it says "All 13 cues match but are 500 ms late."

Classification kinds

identical, timing_shift (constant offset), timing_drift (growing offset), text_change, formatting_change (tags/entities only), whitespace_change (CEA-608 padding only), encoding_change (non-ASCII/accents only), split_cues, merged_cues, missing_cues, extra_cues, unsupported (no cues parsed), or mixed. Each result also carries a per-cue changes list (which cue, what kind, expected/actual snippet, timing offset).

Grounded in CCExtractor's own behaviour

  • Mirrors tests/extract_expected.py's normalization (strip styling tags, unescape entities, trim CEA-608 trailing padding) so cosmetic differences are separated from real text changes.
  • Handles the -latin1 charset case (accent folding → encoding_change).
  • Verified on real CCExtractor output (CEA-608 English + DVB Spanish with <font> tags and accents), vendored as golden fixtures.

Where it lives

  • mod_test/smartdiff/ — a Flask-decoupled core (SRT + WebVTT parsers, a format dispatcher, normalization, and the classifier). Fully unit-tested.
  • TestResultFile.generate_smart_diff() + a JSON endpoint GET /diff/<test>/<regression>/<output>/smart — reusable by the web UI, a CLI, and agents.
  • A "Smart" option next to the existing "Fail" diff link on the result page (additive; the raw diff is unchanged).

Notes

  • Independent of the REST API work — this is standalone in the platform.
  • Tests: parsers, classifier, normalization, real golden fixtures, robustness (malformed/garbage input), and the model glue.
  • Follow-up (not in this PR): a CLI sp run diff --smart consuming the same endpoint.

gaurav02081 avatar Jun 30 '26 19:06 gaurav02081

@canihavesomecoffee Hi could you take a look at this PR? It just hasn't had eyes on it yet. Also, the SP CLI is live. Once this feature is merged I will wire it into that as well.

gaurav02081 avatar Aug 19 '26 15:08 gaurav02081

Please fix the two new sonarqube issues first.

canihavesomecoffee avatar Oct 31 '26 14:10 canihavesomecoffee