diff options
| -rw-r--r-- | server/internal/transcript/trim.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/server/internal/transcript/trim.go b/server/internal/transcript/trim.go index f2ded4c..a853800 100644 --- a/server/internal/transcript/trim.go +++ b/server/internal/transcript/trim.go @@ -40,6 +40,9 @@ const ( // errs towards smaller candidates, which is the safe direction: a skip into the programme // is worse than a missed advertisement. trimRunWords = 4 + // shortLineWords is where a line is short enough that requiring a full-length run would + // mean requiring nearly all of it to be heard correctly. + shortLineWords = 5 // trimMinWords is the shortest line this can judge. A two-word line gives nothing to look // for, so it is kept rather than guessed at, which is what leaves the music markers alone. trimMinWords = 3 @@ -92,7 +95,7 @@ func trimmed(found []Candidate, master, served []Cue) []Candidate { // never anchor -- which leaves them sitting at the front of a break, widening it. Unlike a // title card, which this deliberately leaves alone, an annotation says what it is by its shape, // so it can be told from an advertisement without guessing. -var annotation = regexp.MustCompile(`^\s*[\[(][^\])]{0,40}[\])]\s*$`) +var annotation = regexp.MustCompile(`^\s*(?:[\[(][^\])]{0,40}[\])]|[\x{266a}\x{266b}\x{2669}\x{266c}\s]+)\s*$`) // inMaster reports whether a line's words appear in the master. // trimmable reports whether a line at the edge of a break belongs to the break. @@ -105,7 +108,14 @@ func inMaster(cue Cue, runs map[string]bool) bool { if len(words) < trimMinWords { return false } + // A short line is judged on a shorter run. Four words out of four means one misheard word + // anywhere in it hides the whole line -- which is how "I'm Jack Rhysider" came back as + // "I'm Jack Resider" and opened three Darknet Diaries breaks on the host's own sentence. + // Three of "i m jack resider" still finds "i m jack" in the master. size := trimRunWords + if len(words) <= shortLineWords { + size = trimMinWords + } if len(words) < size { size = len(words) } |
