Centralize segment reference fallback in model
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package model
|
||||
|
||||
import "fmt"
|
||||
|
||||
// RawTranscript is a loaded input document before canonical normalization.
|
||||
type RawTranscript struct {
|
||||
Source string `json:"source"`
|
||||
@@ -61,6 +63,17 @@ type Segment struct {
|
||||
OverlapGroupID int `json:"overlap_group_id,omitempty"`
|
||||
}
|
||||
|
||||
// SegmentReference returns the best available external reference for a segment.
|
||||
func SegmentReference(segment Segment) string {
|
||||
if segment.Source != "" && segment.SourceSegmentIndex != nil {
|
||||
return fmt.Sprintf("%s#%d", segment.Source, *segment.SourceSegmentIndex)
|
||||
}
|
||||
if segment.SourceRef != "" {
|
||||
return segment.SourceRef
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Word preserves optional word-level timing data.
|
||||
type Word struct {
|
||||
Text string `json:"text"`
|
||||
|
||||
Reference in New Issue
Block a user