crosslang

package
v0.2.40 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package crosslang implements cross-language subtitle alignment using anchor-based matching and dynamic programming.

Index

Constants

View Source
const MinCuesForSync = 5

MinCuesForSync is the minimum number of cues required for alignment. Must match subsync.MinCuesForSync — kept as a const here to avoid a circular import between subsync and crosslang.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anchor

type Anchor struct {
	Punctuation string
	Numbers     []string
	ProperNouns []string
	Cognates    []string
	WordCount   int
	CharLen     int
}

Anchor represents language-independent features extracted from a subtitle cue.

type Cue

type Cue struct {
	Text  string
	Start time.Duration
	End   time.Duration
}

Cue represents a single subtitle cue with timing and text. Structurally identical to subsync.Cue to allow zero-copy conversion.

type CuePair

type CuePair struct {
	IncIdx   int
	RefIdx   int
	Score    float64
	OffsetMs int64
}

CuePair holds a matched pair of cues with their similarity score. Exported for test compatibility with the parent subsync package.

type Result

type Result struct {
	Cues       []Cue
	Offset     int64   // milliseconds
	Rate       float64 // always 1.0 for crosslang
	Confidence float64
}

Result holds the output of cross-language alignment.

func Align

func Align(ctx context.Context, reference, incorrect []Cue) Result

Align finds the best constant offset between reference and incorrect subtitles using cross-language anchor matching.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL