-
Notifications
You must be signed in to change notification settings - Fork 0
/
add-context.go
37 lines (29 loc) · 892 Bytes
/
add-context.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
func ProcessRawCaptions(url string, rawCaptions []RawCaption) []Caption {
captions := make([]Caption, len(rawCaptions))
// Iterate over the rawCaptions
for i, rawCaption := range rawCaptions {
var context string
// Add previous RawCaption text to the context, if available
if i > 0 {
context += rawCaptions[i-1].Text + " "
}
// Add current RawCaption text to the context
context += rawCaption.Text + " "
// Add next RawCaption text to the context, if available
if i < len(rawCaptions)-1 {
context += rawCaptions[i+1].Text
}
caption := Caption{
Url: url,
Index: rawCaption.Index,
Text: rawCaption.Text,
Context: context,
TimestampFrom: rawCaption.TimestampFrom,
TimestampTo: rawCaption.TimestampTo,
ClipLength: rawCaption.ClipLength,
}
captions[i] = caption
}
return captions
}