fixer_test.go 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. package sub_timeline_fixer
  2. import (
  3. "fmt"
  4. "github.com/allanpk716/ChineseSubFinder/internal/logic/sub_parser/ass"
  5. "github.com/allanpk716/ChineseSubFinder/internal/logic/sub_parser/srt"
  6. "github.com/allanpk716/ChineseSubFinder/internal/pkg/debug_view"
  7. "github.com/allanpk716/ChineseSubFinder/internal/pkg/ffmpeg_helper"
  8. "github.com/allanpk716/ChineseSubFinder/internal/pkg/my_util"
  9. "github.com/allanpk716/ChineseSubFinder/internal/pkg/sub_helper"
  10. "github.com/allanpk716/ChineseSubFinder/internal/pkg/sub_parser_hub"
  11. "github.com/allanpk716/ChineseSubFinder/internal/pkg/vad"
  12. "github.com/allanpk716/ChineseSubFinder/internal/types/sub_timeline_fiexer"
  13. "github.com/james-bowman/nlp"
  14. "github.com/james-bowman/nlp/measures/pairwise"
  15. "gonum.org/v1/gonum/mat"
  16. "path/filepath"
  17. "strings"
  18. "testing"
  19. )
  20. func TestStopWordCounter(t *testing.T) {
  21. testDataPath := "../../../TestData/FixTimeline"
  22. testRootDir, err := my_util.CopyTestData(testDataPath)
  23. if err != nil {
  24. t.Fatal(err)
  25. }
  26. subParserHub := sub_parser_hub.NewSubParserHub(ass.NewParser(), srt.NewParser())
  27. bFind, info, err := subParserHub.DetermineFileTypeFromFile(filepath.Join(testRootDir, "R&M S05E10 - English.srt"))
  28. if err != nil {
  29. t.Fatal(err)
  30. }
  31. if bFind == false {
  32. t.Fatal("not match sub types")
  33. }
  34. allString := strings.Join(info.OtherLines, " ")
  35. s := SubTimelineFixer{}
  36. stopWords := s.StopWordCounter(strings.ToLower(allString), 5)
  37. print(len(stopWords))
  38. println(info.Name)
  39. }
  40. func TestTFIDF(t *testing.T) {
  41. testCorpus := []string{
  42. "The quick brown fox jumped over the lazy dog",
  43. "hey diddle diddle, the cat and the fiddle",
  44. "the cow jumped over the moon",
  45. "the little dog laughed to see such fun",
  46. "and the dish ran away with the spoon",
  47. }
  48. query := "the brown fox ran around the dog"
  49. vectoriser := nlp.NewCountVectoriser(StopWords...)
  50. transformer := nlp.NewTfidfTransformer()
  51. // set k (the number of dimensions following truncation) to 4
  52. reducer := nlp.NewTruncatedSVD(4)
  53. lsiPipeline := nlp.NewPipeline(vectoriser, transformer, reducer)
  54. // Transform the corpus into an LSI fitting the model to the documents in the process
  55. lsi, err := lsiPipeline.FitTransform(testCorpus...)
  56. if err != nil {
  57. fmt.Printf("Failed to process documents because %v", err)
  58. return
  59. }
  60. // run the query through the same pipeline that was fitted to the corpus and
  61. // to project it into the same dimensional space
  62. queryVector, err := lsiPipeline.Transform(query)
  63. if err != nil {
  64. fmt.Printf("Failed to process documents because %v", err)
  65. return
  66. }
  67. // iterate over document feature vectors (columns) in the LSI matrix and compare
  68. // with the query vector for similarity. Similarity is determined by the difference
  69. // between the angles of the vectors known as the cosine similarity
  70. highestSimilarity := -1.0
  71. var matched int
  72. _, docs := lsi.Dims()
  73. for i := 0; i < docs; i++ {
  74. similarity := pairwise.CosineSimilarity(queryVector.(mat.ColViewer).ColView(0), lsi.(mat.ColViewer).ColView(i))
  75. if similarity > highestSimilarity {
  76. matched = i
  77. highestSimilarity = similarity
  78. }
  79. }
  80. fmt.Printf("Matched '%s'", testCorpus[matched])
  81. // Output: Matched 'The quick brown fox jumped over the lazy dog'
  82. }
  83. func TestGetOffsetTimeV1(t *testing.T) {
  84. testDataPath := "../../../TestData/FixTimeline"
  85. testRootDir, err := my_util.CopyTestData(testDataPath)
  86. if err != nil {
  87. t.Fatal(err)
  88. }
  89. testRootDirYes := filepath.Join(testRootDir, "yes")
  90. testRootDirNo := filepath.Join(testRootDir, "no")
  91. subParserHub := sub_parser_hub.NewSubParserHub(ass.NewParser(), srt.NewParser())
  92. type args struct {
  93. enSubFile string
  94. ch_enSubFile string
  95. staticLineFileSavePath string
  96. }
  97. tests := []struct {
  98. name string
  99. args args
  100. want float64
  101. wantErr bool
  102. }{
  103. /*
  104. 这里有几个比较理想的字幕时间轴校正的示例
  105. */
  106. {name: "R&M S05E01", args: args{enSubFile: filepath.Join(testRootDirYes, "R&M S05E01 - English.srt"),
  107. ch_enSubFile: filepath.Join(testRootDirYes, "R&M S05E01 - 简英.srt"),
  108. staticLineFileSavePath: "bar.html"}, want: -6.42981818181818, wantErr: false},
  109. {name: "R&M S05E10", args: args{enSubFile: filepath.Join(testRootDirYes, "R&M S05E10 - English.ass"),
  110. ch_enSubFile: filepath.Join(testRootDirYes, "R&M S05E10 - 简英.ass"),
  111. staticLineFileSavePath: "bar.html"}, want: -6.335985401459854, wantErr: false},
  112. {name: "基地 S01E03", args: args{enSubFile: filepath.Join(testRootDirYes, "基地 S01E03 - English.ass"),
  113. ch_enSubFile: filepath.Join(testRootDirYes, "基地 S01E03 - 简英.ass"),
  114. staticLineFileSavePath: "bar.html"}, want: -32.09061538461539, wantErr: false},
  115. /*
  116. WTF,这部剧集
  117. Dan Brown'timelineFixer The Lost Symbol
  118. 内置的英文字幕时间轴是歪的,所以修正完了就错了
  119. */
  120. {name: "Dan Brown'timelineFixer The Lost Symbol - S01E01", args: args{
  121. enSubFile: filepath.Join(testRootDirNo, "Dan Brown's The Lost Symbol - S01E01.chinese(inside).ass"),
  122. ch_enSubFile: filepath.Join(testRootDirNo, "Dan Brown's The Lost Symbol - S01E01.chinese(简英,shooter).ass"),
  123. staticLineFileSavePath: "bar.html"},
  124. want: 1.3217821782178225, wantErr: false},
  125. {name: "Dan Brown'timelineFixer The Lost Symbol - S01E02", args: args{
  126. enSubFile: filepath.Join(testRootDirNo, "Dan Brown's The Lost Symbol - S01E02.chinese(inside).ass"),
  127. ch_enSubFile: filepath.Join(testRootDirNo, "Dan Brown's The Lost Symbol - S01E02.chinese(简英,subhd).ass"),
  128. staticLineFileSavePath: "bar.html"},
  129. want: -0.5253383458646617, wantErr: false},
  130. {name: "Dan Brown'timelineFixer The Lost Symbol - S01E03", args: args{
  131. enSubFile: filepath.Join(testRootDirNo, "Dan Brown's The Lost Symbol - S01E03.chinese(inside).ass"),
  132. ch_enSubFile: filepath.Join(testRootDirNo, "Dan Brown's The Lost Symbol - S01E03.chinese(繁英,xunlei).ass"),
  133. staticLineFileSavePath: "bar.html"},
  134. want: -0.505656, wantErr: false},
  135. {name: "Dan Brown'timelineFixer The Lost Symbol - S01E04", args: args{
  136. enSubFile: filepath.Join(testRootDirNo, "Dan Brown's The Lost Symbol - S01E04.chinese(inside).ass"),
  137. ch_enSubFile: filepath.Join(testRootDirNo, "Dan Brown's The Lost Symbol - S01E04.chinese(简英,zimuku).ass"),
  138. staticLineFileSavePath: "bar.html"},
  139. want: -0.633415, wantErr: false},
  140. /*
  141. 只有一个是字幕下载了一个错误的,其他的无需修正
  142. */
  143. {name: "Don't Breathe 2 (2021) - shooter-srt", args: args{
  144. enSubFile: filepath.Join(testRootDirNo, "Don't Breathe 2 (2021).chinese(inside).srt"),
  145. ch_enSubFile: filepath.Join(testRootDirNo, "Don't Breathe 2 (2021).chinese(简英,shooter).srt"),
  146. staticLineFileSavePath: "bar.html"},
  147. want: 0, wantErr: false},
  148. {name: "Don't Breathe 2 (2021) - subhd-srt error matched sub", args: args{
  149. enSubFile: filepath.Join(testRootDirNo, "Don't Breathe 2 (2021).chinese(inside).srt"),
  150. ch_enSubFile: filepath.Join(testRootDirNo, "Don't Breathe 2 (2021).chinese(简英,subhd).srt"),
  151. staticLineFileSavePath: "bar.html"},
  152. want: 0, wantErr: false},
  153. {name: "Don't Breathe 2 (2021) - xunlei-ass", args: args{
  154. enSubFile: filepath.Join(testRootDirNo, "Don't Breathe 2 (2021).chinese(inside).ass"),
  155. ch_enSubFile: filepath.Join(testRootDirNo, "Don't Breathe 2 (2021).chinese(简英,xunlei).ass"),
  156. staticLineFileSavePath: "bar.html"},
  157. want: 0, wantErr: false},
  158. {name: "Don't Breathe 2 (2021) - zimuku-ass", args: args{
  159. enSubFile: filepath.Join(testRootDirNo, "Don't Breathe 2 (2021).chinese(inside).ass"),
  160. ch_enSubFile: filepath.Join(testRootDirNo, "Don't Breathe 2 (2021).chinese(简英,zimuku).ass"),
  161. staticLineFileSavePath: "bar.html"},
  162. want: 0, wantErr: false},
  163. /*
  164. 基地
  165. */
  166. {name: "Foundation (2021) - S01E01", args: args{
  167. enSubFile: filepath.Join(testRootDirNo, "Foundation (2021) - S01E01.chinese(inside).ass"),
  168. ch_enSubFile: filepath.Join(testRootDirNo, "Foundation (2021) - S01E01.chinese(简英,zimuku).ass"),
  169. staticLineFileSavePath: "bar.html"},
  170. want: 0, wantErr: false},
  171. {name: "Foundation (2021) - S01E02", args: args{
  172. enSubFile: filepath.Join(testRootDirYes, "Foundation (2021) - S01E02.chinese(inside).ass"),
  173. ch_enSubFile: filepath.Join(testRootDirYes, "Foundation (2021) - S01E02.chinese(简英,subhd).ass"),
  174. staticLineFileSavePath: "bar.html"},
  175. want: -30.624840, wantErr: false},
  176. {name: "Foundation (2021) - S01E03", args: args{
  177. enSubFile: filepath.Join(testRootDirYes, "Foundation (2021) - S01E03.chinese(inside).ass"),
  178. ch_enSubFile: filepath.Join(testRootDirYes, "Foundation (2021) - S01E03.chinese(简英,subhd).ass"),
  179. staticLineFileSavePath: "bar.html"},
  180. want: -32.085037037037054, wantErr: false},
  181. {name: "Foundation (2021) - S01E04", args: args{
  182. enSubFile: filepath.Join(testRootDirYes, "Foundation (2021) - S01E04.chinese(inside).ass"),
  183. ch_enSubFile: filepath.Join(testRootDirYes, "Foundation (2021) - S01E04.chinese(简英,subhd).ass"),
  184. staticLineFileSavePath: "bar.html"},
  185. want: -36.885074, wantErr: false},
  186. {name: "Foundation (2021) - S01E04", args: args{
  187. enSubFile: filepath.Join(testRootDirNo, "Foundation (2021) - S01E04.chinese(inside).srt"),
  188. ch_enSubFile: filepath.Join(testRootDirNo, "Foundation (2021) - S01E04.chinese(繁英,shooter).srt"),
  189. staticLineFileSavePath: "bar.html"},
  190. want: 0, wantErr: false},
  191. /*
  192. The Card Counter
  193. */
  194. {name: "The Card Counter", args: args{
  195. enSubFile: filepath.Join(testRootDirNo, "The Card Counter (2021).chinese(inside).ass"),
  196. ch_enSubFile: filepath.Join(testRootDirNo, "The Card Counter (2021).chinese(简英,xunlei).ass"),
  197. staticLineFileSavePath: "bar.html"},
  198. want: 0, wantErr: false},
  199. {name: "The Card Counter", args: args{
  200. enSubFile: filepath.Join(testRootDirNo, "The Card Counter (2021).chinese(inside).ass"),
  201. ch_enSubFile: filepath.Join(testRootDirNo, "The Card Counter (2021).chinese(简英,shooter).ass"),
  202. staticLineFileSavePath: "bar.html"},
  203. want: 0.224844, wantErr: false},
  204. /*
  205. Kingdom Ashin of the North
  206. */
  207. {name: "Kingdom Ashin of the North - error matched sub", args: args{
  208. enSubFile: filepath.Join(testRootDirNo, "Kingdom Ashin of the North (2021).chinese(inside).ass"),
  209. ch_enSubFile: filepath.Join(testRootDirNo, "Kingdom Ashin of the North (2021).chinese(简英,subhd).ass"),
  210. staticLineFileSavePath: "bar.html"},
  211. want: 0, wantErr: false},
  212. /*
  213. Only Murders in the Building
  214. */
  215. {name: "Only Murders in the Building - S01E06", args: args{
  216. enSubFile: filepath.Join(testRootDirNo, "Only Murders in the Building - S01E06.chinese(inside).ass"),
  217. ch_enSubFile: filepath.Join(testRootDirNo, "Only Murders in the Building - S01E06.chinese(简英,subhd).ass"),
  218. staticLineFileSavePath: "bar.html"},
  219. want: 0, wantErr: false},
  220. {name: "Only Murders in the Building - S01E08", args: args{
  221. enSubFile: filepath.Join(testRootDirNo, "Only Murders in the Building - S01E08.chinese(inside).ass"),
  222. ch_enSubFile: filepath.Join(testRootDirNo, "Only Murders in the Building - S01E08.chinese(简英,subhd).ass"),
  223. staticLineFileSavePath: "bar.html"},
  224. want: 0, wantErr: false},
  225. /*
  226. Ted Lasso
  227. */
  228. {name: "Ted Lasso - S02E09", args: args{
  229. enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E09.chinese(inside).ass"),
  230. ch_enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E09.chinese(简英,subhd).ass"),
  231. staticLineFileSavePath: "bar.html"},
  232. want: 0, wantErr: false},
  233. {name: "Ted Lasso - S02E09", args: args{
  234. enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E09.chinese(inside).ass"),
  235. ch_enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E09.chinese(简英,zimuku).ass"),
  236. staticLineFileSavePath: "bar.html"},
  237. want: 0, wantErr: false},
  238. {name: "Ted Lasso - S02E10", args: args{
  239. enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E10.chinese(inside).ass"),
  240. ch_enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E10.chinese(简英,subhd).ass"),
  241. staticLineFileSavePath: "bar.html"},
  242. want: 0, wantErr: false},
  243. {name: "Ted Lasso - S02E10", args: args{
  244. enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E10.chinese(inside).ass"),
  245. ch_enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E10.chinese(简英,zimuku).ass"),
  246. staticLineFileSavePath: "bar.html"},
  247. want: 0, wantErr: false},
  248. {name: "Ted Lasso - S02E10", args: args{
  249. enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E10.chinese(inside).ass"),
  250. ch_enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E10.chinese(简英,shooter).ass"),
  251. staticLineFileSavePath: "bar.html"},
  252. want: 0, wantErr: false},
  253. {name: "Ted Lasso - S02E11", args: args{
  254. enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E11.chinese(inside).ass"),
  255. ch_enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E11.chinese(简英,subhd).ass"),
  256. staticLineFileSavePath: "bar.html"},
  257. want: 0, wantErr: false},
  258. {name: "Ted Lasso - S02E11", args: args{
  259. enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E11.chinese(inside).ass"),
  260. ch_enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E11.chinese(简英,zimuku).ass"),
  261. staticLineFileSavePath: "bar.html"},
  262. want: 0, wantErr: false},
  263. {name: "Ted Lasso - S02E12", args: args{
  264. enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E12.chinese(inside).ass"),
  265. ch_enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E12.chinese(简英,subhd).ass"),
  266. staticLineFileSavePath: "bar.html"},
  267. want: 0, wantErr: false},
  268. {name: "Ted Lasso - S02E12", args: args{
  269. enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E12.chinese(inside).ass"),
  270. ch_enSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E12.chinese(简英,shooter).ass"),
  271. staticLineFileSavePath: "bar.html"},
  272. want: 0, wantErr: false},
  273. /*
  274. The Protégé
  275. */
  276. {name: "The Protégé", args: args{
  277. enSubFile: filepath.Join(testRootDirNo, "The Protégé (2021).chinese(inside).ass"),
  278. ch_enSubFile: filepath.Join(testRootDirNo, "The Protégé (2021).chinese(简英,zimuku).ass"),
  279. staticLineFileSavePath: "bar.html"},
  280. want: 0, wantErr: false},
  281. {name: "The Protégé", args: args{
  282. enSubFile: filepath.Join(testRootDirNo, "The Protégé (2021).chinese(inside).srt"),
  283. ch_enSubFile: filepath.Join(testRootDirNo, "The Protégé (2021).chinese(简英,shooter).srt"),
  284. staticLineFileSavePath: "bar.html"},
  285. want: 0, wantErr: false},
  286. /*
  287. The Witcher Nightmare of the Wolf
  288. */
  289. {name: "The Witcher Nightmare of the Wolf", args: args{
  290. enSubFile: filepath.Join(testRootDirNo, "The Witcher Nightmare of the Wolf.chinese(inside).ass"),
  291. ch_enSubFile: filepath.Join(testRootDirNo, "The Witcher Nightmare of the Wolf.chinese(简英,zimuku).ass"),
  292. staticLineFileSavePath: "bar.html"},
  293. want: 0, wantErr: false},
  294. /*
  295. What If…!
  296. */
  297. {name: "What If…! - S01E07", args: args{
  298. enSubFile: filepath.Join(testRootDirNo, "What If…! - S01E07.chinese(inside).ass"),
  299. ch_enSubFile: filepath.Join(testRootDirNo, "What If…! - S01E07.chinese(简英,subhd).ass"),
  300. staticLineFileSavePath: "bar.html"},
  301. want: 0, wantErr: false},
  302. {name: "What If…! - S01E09", args: args{
  303. enSubFile: filepath.Join(testRootDirNo, "What If…! - S01E09.chinese(inside).srt"),
  304. ch_enSubFile: filepath.Join(testRootDirNo, "What If…! - S01E09.chinese(简英,shooter).srt"),
  305. staticLineFileSavePath: "bar.html"},
  306. want: 0, wantErr: false},
  307. }
  308. timelineFixer := NewSubTimelineFixer(sub_timeline_fiexer.SubTimelineFixerConfig{
  309. MaxCompareDialogue: 3,
  310. MaxStartTimeDiffSD: 0.1,
  311. MinMatchedPercent: 0.1,
  312. MinOffset: 0.1,
  313. })
  314. for _, tt := range tests {
  315. t.Run(tt.name, func(t *testing.T) {
  316. bFind, infoBase, err := subParserHub.DetermineFileTypeFromFile(tt.args.enSubFile)
  317. if err != nil {
  318. t.Fatal(err)
  319. }
  320. if bFind == false {
  321. t.Fatal("sub not match")
  322. }
  323. /*
  324. 这里发现一个梗,内置的英文字幕导出的时候,有可能需要合并多个 Dialogue,见
  325. internal/pkg/sub_helper/sub_helper.go 中 MergeMultiDialogue4EngSubtitle 的实现
  326. */
  327. sub_helper.MergeMultiDialogue4EngSubtitle(infoBase)
  328. bFind, infoSrc, err := subParserHub.DetermineFileTypeFromFile(tt.args.ch_enSubFile)
  329. if err != nil {
  330. t.Fatal(err)
  331. }
  332. if bFind == false {
  333. t.Fatal("sub not match")
  334. }
  335. /*
  336. 这里发现一个梗,内置的英文字幕导出的时候,有可能需要合并多个 Dialogue,见
  337. internal/pkg/sub_helper/sub_helper.go 中 MergeMultiDialogue4EngSubtitle 的实现
  338. */
  339. sub_helper.MergeMultiDialogue4EngSubtitle(infoSrc)
  340. bok, got, sd, err := timelineFixer.GetOffsetTimeV1(infoBase, infoSrc, tt.args.ch_enSubFile+"-bar.html", tt.args.ch_enSubFile+".log")
  341. if (err != nil) != tt.wantErr {
  342. t.Errorf("GetOffsetTimeV1() error = %v, wantErr %v", err, tt.wantErr)
  343. return
  344. }
  345. // 在一个正负范围内都可以接受
  346. if got > tt.want-0.1 && got < tt.want+0.1 {
  347. } else {
  348. t.Errorf("GetOffsetTimeV1() got = %v, want %v", got, tt.want)
  349. }
  350. //if got != tt.want {
  351. // t.Errorf("GetOffsetTimeV1() got = %v, want %v", got, tt.want)
  352. //}
  353. if bok == true && got != 0 {
  354. _, err = timelineFixer.FixSubTimeline(infoSrc, got, tt.args.ch_enSubFile+FixMask+infoBase.Ext)
  355. if err != nil {
  356. t.Fatal(err)
  357. }
  358. }
  359. println(fmt.Sprintf("GetOffsetTimeV1: %fs SD:%f", got, sd))
  360. })
  361. }
  362. }
  363. func TestGetOffsetTimeV2_BaseSub(t *testing.T) {
  364. testDataPath := "../../../TestData/FixTimeline"
  365. testRootDir, err := my_util.CopyTestData(testDataPath)
  366. if err != nil {
  367. t.Fatal(err)
  368. }
  369. testRootDirYes := filepath.Join(testRootDir, "yes")
  370. testRootDirNo := filepath.Join(testRootDir, "no")
  371. subParserHub := sub_parser_hub.NewSubParserHub(ass.NewParser(), srt.NewParser())
  372. type args struct {
  373. baseSubFile string
  374. srcSubFile string
  375. staticLineFileSavePath string
  376. }
  377. tests := []struct {
  378. name string
  379. args args
  380. want float64
  381. wantErr bool
  382. }{
  383. /*
  384. 这里有几个比较理想的字幕时间轴校正的示例
  385. */
  386. {name: "R&M S05E01", args: args{baseSubFile: filepath.Join(testRootDirYes, "R&M S05E01 - English.srt"),
  387. srcSubFile: filepath.Join(testRootDirYes, "R&M S05E01 - 简英.srt"),
  388. staticLineFileSavePath: "bar.html"}, want: -6.12981818181818, wantErr: false},
  389. {name: "R&M S05E01-1", args: args{baseSubFile: filepath.Join(testRootDirYes, "R&M S05E01 - English.srt"),
  390. srcSubFile: filepath.Join(testRootDirYes, "R&M S05E01 - English.srt"),
  391. staticLineFileSavePath: "bar.html"}, want: 0, wantErr: false},
  392. {name: "R&M S05E10", args: args{baseSubFile: filepath.Join(testRootDirYes, "R&M S05E10 - English.ass"),
  393. srcSubFile: filepath.Join(testRootDirYes, "R&M S05E10 - 简英.ass"),
  394. staticLineFileSavePath: "bar.html"}, want: -6.405985401459854, wantErr: false},
  395. {name: "R&M S05E10-1", args: args{baseSubFile: filepath.Join(testRootDirYes, "R&M S05E10 - 简英.ass"),
  396. srcSubFile: filepath.Join(testRootDirYes, "R&M S05E10 - English.ass"),
  397. staticLineFileSavePath: "bar.html"}, want: 6.405985401459854, wantErr: false},
  398. {name: "R&M S05E10-2", args: args{baseSubFile: filepath.Join(testRootDirYes, "R&M S05E10 - 简英.ass"),
  399. srcSubFile: filepath.Join(testRootDirYes, "R&M S05E10 - 简英.ass"),
  400. staticLineFileSavePath: "bar.html"}, want: 0, wantErr: false},
  401. {name: "R&M S05E01-2", args: args{
  402. baseSubFile: "C:\\Tmp\\Rick and Morty - S05E01\\英_2.srt",
  403. srcSubFile: "C:\\Tmp\\Rick and Morty - S05E01\\Rick and Morty - S05E01 - Mort Dinner Rick Andre WEBDL-1080p.chinese(简英,zimuku).ass",
  404. staticLineFileSavePath: "bar.html"}, want: -6.12981818181818, wantErr: false},
  405. {name: "R&M S05E01-2", args: args{
  406. baseSubFile: "C:\\Tmp\\Rick and Morty - S05E01\\英_2.ass",
  407. srcSubFile: "C:\\Tmp\\Rick and Morty - S05E01\\Rick and Morty - S05E01 - Mort Dinner Rick Andre WEBDL-1080p.chinese(简英,zimuku).ass",
  408. staticLineFileSavePath: "bar.html"}, want: -6.12981818181818, wantErr: false},
  409. {name: "R&M S05E01-2", args: args{
  410. baseSubFile: "C:\\Tmp\\Rick and Morty - S05E01\\英_2.ass",
  411. srcSubFile: "C:\\Tmp\\Rick and Morty - S05E01\\英_2.srt",
  412. staticLineFileSavePath: "bar.html"}, want: 0, wantErr: false},
  413. {name: "R&M S05E01-2", args: args{
  414. baseSubFile: "C:\\Tmp\\Rick and Morty - S05E10\\英_2.srt",
  415. srcSubFile: "C:\\Tmp\\Rick and Morty - S05E10\\英_2.ass",
  416. staticLineFileSavePath: "bar.html"}, want: 0, wantErr: false},
  417. /*
  418. 基地
  419. */
  420. {name: "Foundation (2021) - S01E01", args: args{
  421. baseSubFile: filepath.Join(testRootDirNo, "Foundation (2021) - S01E01.chinese(inside).ass"),
  422. srcSubFile: filepath.Join(testRootDirNo, "Foundation (2021) - S01E01.chinese(简英,zimuku).ass"),
  423. staticLineFileSavePath: "bar.html"},
  424. want: 0, wantErr: false},
  425. {name: "Foundation (2021) - S01E02", args: args{
  426. baseSubFile: filepath.Join(testRootDirYes, "Foundation (2021) - S01E02.chinese(inside).ass"),
  427. srcSubFile: filepath.Join(testRootDirYes, "Foundation (2021) - S01E02.chinese(简英,subhd).ass"),
  428. staticLineFileSavePath: "bar.html"},
  429. want: -30.624840, wantErr: false},
  430. {name: "Foundation (2021) - S01E03", args: args{
  431. baseSubFile: filepath.Join(testRootDirYes, "Foundation (2021) - S01E03.chinese(inside).ass"),
  432. srcSubFile: filepath.Join(testRootDirYes, "Foundation (2021) - S01E03.chinese(简英,subhd).ass"),
  433. staticLineFileSavePath: "bar.html"},
  434. want: -32.085037037037054, wantErr: false},
  435. {name: "Foundation (2021) - S01E04", args: args{
  436. baseSubFile: filepath.Join(testRootDirYes, "Foundation (2021) - S01E04.chinese(inside).ass"),
  437. srcSubFile: filepath.Join(testRootDirYes, "Foundation (2021) - S01E04.chinese(简英,subhd).ass"),
  438. staticLineFileSavePath: "bar.html"},
  439. want: -36.885074, wantErr: false},
  440. {name: "Foundation (2021) - S01E04", args: args{
  441. baseSubFile: filepath.Join(testRootDirNo, "Foundation (2021) - S01E04.chinese(inside).srt"),
  442. srcSubFile: filepath.Join(testRootDirNo, "Foundation (2021) - S01E04.chinese(繁英,shooter).srt"),
  443. staticLineFileSavePath: "bar.html"},
  444. want: 0, wantErr: false},
  445. /*
  446. Don't Breathe 2 (2021)
  447. */
  448. {name: "Don't Breathe 2 (2021) - zimuku-ass", args: args{
  449. baseSubFile: filepath.Join(testRootDirNo, "Don't Breathe 2 (2021).chinese(inside).ass"),
  450. srcSubFile: filepath.Join(testRootDirNo, "Don't Breathe 2 (2021).chinese(简英,zimuku).ass"),
  451. staticLineFileSavePath: "bar.html"},
  452. want: 0, wantErr: false},
  453. {name: "Don't Breathe 2 (2021) - shooter-srt", args: args{
  454. baseSubFile: filepath.Join(testRootDirNo, "Don't Breathe 2 (2021).chinese(inside).srt"),
  455. srcSubFile: filepath.Join(testRootDirNo, "Don't Breathe 2 (2021).chinese(简英,shooter).srt"),
  456. staticLineFileSavePath: "bar.html"},
  457. want: 0, wantErr: false},
  458. /*
  459. Only Murders in the Building
  460. */
  461. {name: "Only Murders in the Building - S01E06", args: args{
  462. baseSubFile: filepath.Join(testRootDirNo, "Only Murders in the Building - S01E06.chinese(inside).ass"),
  463. srcSubFile: filepath.Join(testRootDirNo, "Only Murders in the Building - S01E06.chinese(简英,subhd).ass"),
  464. staticLineFileSavePath: "bar.html"},
  465. want: 0, wantErr: false},
  466. {name: "Only Murders in the Building - S01E08", args: args{
  467. baseSubFile: filepath.Join(testRootDirNo, "Only Murders in the Building - S01E08.chinese(inside).ass"),
  468. srcSubFile: filepath.Join(testRootDirNo, "Only Murders in the Building - S01E08.chinese(简英,subhd).ass"),
  469. staticLineFileSavePath: "bar.html"},
  470. want: 0, wantErr: false},
  471. /*
  472. Ted Lasso
  473. */
  474. {name: "Ted Lasso - S02E09", args: args{
  475. baseSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E09.chinese(inside).ass"),
  476. srcSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E09.chinese(简英,subhd).ass"),
  477. staticLineFileSavePath: "bar.html"},
  478. want: 0, wantErr: false},
  479. {name: "Ted Lasso - S02E09", args: args{
  480. baseSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E09.chinese(inside).ass"),
  481. srcSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E09.chinese(简英,zimuku).ass"),
  482. staticLineFileSavePath: "bar.html"},
  483. want: 0, wantErr: false},
  484. {name: "Ted Lasso - S02E10", args: args{
  485. baseSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E10.chinese(inside).ass"),
  486. srcSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E10.chinese(简英,subhd).ass"),
  487. staticLineFileSavePath: "bar.html"},
  488. want: 0, wantErr: false},
  489. {name: "Ted Lasso - S02E10", args: args{
  490. baseSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E10.chinese(inside).ass"),
  491. srcSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E10.chinese(简英,zimuku).ass"),
  492. staticLineFileSavePath: "bar.html"},
  493. want: 0, wantErr: false},
  494. {name: "Ted Lasso - S02E10", args: args{
  495. baseSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E10.chinese(inside).ass"),
  496. srcSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E10.chinese(简英,shooter).ass"),
  497. staticLineFileSavePath: "bar.html"},
  498. want: 0, wantErr: false},
  499. {name: "Ted Lasso - S02E11", args: args{
  500. baseSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E11.chinese(inside).ass"),
  501. srcSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E11.chinese(简英,subhd).ass"),
  502. staticLineFileSavePath: "bar.html"},
  503. want: 0, wantErr: false},
  504. {name: "Ted Lasso - S02E11", args: args{
  505. baseSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E11.chinese(inside).ass"),
  506. srcSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E11.chinese(简英,zimuku).ass"),
  507. staticLineFileSavePath: "bar.html"},
  508. want: 0, wantErr: false},
  509. {name: "Ted Lasso - S02E12", args: args{
  510. baseSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E12.chinese(inside).ass"),
  511. srcSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E12.chinese(简英,subhd).ass"),
  512. staticLineFileSavePath: "bar.html"},
  513. want: 0, wantErr: false},
  514. {name: "Ted Lasso - S02E12", args: args{
  515. baseSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E12.chinese(inside).ass"),
  516. srcSubFile: filepath.Join(testRootDirNo, "Ted Lasso - S02E12.chinese(简英,shooter).ass"),
  517. staticLineFileSavePath: "bar.html"},
  518. want: 0, wantErr: false},
  519. /*
  520. The Protégé
  521. */
  522. {name: "The Protégé", args: args{
  523. baseSubFile: filepath.Join(testRootDirNo, "The Protégé (2021).chinese(inside).ass"),
  524. srcSubFile: filepath.Join(testRootDirNo, "The Protégé (2021).chinese(简英,zimuku).ass"),
  525. staticLineFileSavePath: "bar.html"},
  526. want: 0, wantErr: false},
  527. {name: "The Protégé", args: args{
  528. baseSubFile: filepath.Join(testRootDirNo, "The Protégé (2021).chinese(inside).srt"),
  529. srcSubFile: filepath.Join(testRootDirNo, "The Protégé (2021).chinese(简英,shooter).srt"),
  530. staticLineFileSavePath: "bar.html"},
  531. want: 0, wantErr: false},
  532. /*
  533. The Witcher Nightmare of the Wolf
  534. */
  535. {name: "The Witcher Nightmare of the Wolf", args: args{
  536. baseSubFile: filepath.Join(testRootDirNo, "The Witcher Nightmare of the Wolf.chinese(inside).ass"),
  537. srcSubFile: filepath.Join(testRootDirNo, "The Witcher Nightmare of the Wolf.chinese(简英,zimuku).ass"),
  538. staticLineFileSavePath: "bar.html"},
  539. want: 0, wantErr: false},
  540. /*
  541. What If…!
  542. */
  543. {name: "What If…! - S01E07", args: args{
  544. baseSubFile: filepath.Join(testRootDirNo, "What If…! - S01E07.chinese(inside).ass"),
  545. srcSubFile: filepath.Join(testRootDirNo, "What If…! - S01E07.chinese(简英,subhd).ass"),
  546. staticLineFileSavePath: "bar.html"},
  547. want: 0, wantErr: false},
  548. {name: "What If…! - S01E09", args: args{
  549. baseSubFile: filepath.Join(testRootDirNo, "What If…! - S01E09.chinese(inside).srt"),
  550. srcSubFile: filepath.Join(testRootDirNo, "What If…! - S01E09.chinese(简英,shooter).srt"),
  551. staticLineFileSavePath: "bar.html"},
  552. want: 0, wantErr: false},
  553. }
  554. timelineFixer := NewSubTimelineFixer(sub_timeline_fiexer.SubTimelineFixerConfig{
  555. MaxCompareDialogue: 3,
  556. MaxStartTimeDiffSD: 0.1,
  557. MinMatchedPercent: 0.1,
  558. MinOffset: 0.1,
  559. })
  560. for _, tt := range tests {
  561. t.Run(tt.name, func(t *testing.T) {
  562. bFind, infoBase, err := subParserHub.DetermineFileTypeFromFile(tt.args.baseSubFile)
  563. if err != nil {
  564. t.Fatal(err)
  565. }
  566. if bFind == false {
  567. t.Fatal("sub not match")
  568. }
  569. /*
  570. 这里发现一个梗,内置的英文字幕导出的时候,有可能需要合并多个 Dialogue,见
  571. internal/pkg/sub_helper/sub_helper.go 中 MergeMultiDialogue4EngSubtitle 的实现
  572. */
  573. //sub_helper.MergeMultiDialogue4EngSubtitle(infoBase)
  574. bFind, infoSrc, err := subParserHub.DetermineFileTypeFromFile(tt.args.srcSubFile)
  575. if err != nil {
  576. t.Fatal(err)
  577. }
  578. if bFind == false {
  579. t.Fatal("sub not match")
  580. }
  581. /*
  582. 这里发现一个梗,内置的英文字幕导出的时候,有可能需要合并多个 Dialogue,见
  583. internal/pkg/sub_helper/sub_helper.go 中 MergeMultiDialogue4EngSubtitle 的实现
  584. */
  585. //sub_helper.MergeMultiDialogue4EngSubtitle(infoSrc)
  586. // ---------------------------------------------------------------------------------------
  587. // Base,截取的部分要大于 Src 的部分
  588. //baseUnitList, err := sub_helper.GetVADInfosFromSub(infoBase, FrontAndEndPerBase, 1)
  589. //if err != nil {
  590. // t.Fatal(err)
  591. //}
  592. //baseUnit := baseUnitList[0]
  593. baseUnitList2, err := sub_helper.GetVADInfoFeatureFromSub(infoBase, FrontAndEndPerBase, 100000, true)
  594. if err != nil {
  595. t.Fatal(err)
  596. }
  597. baseUnit := baseUnitList2[0]
  598. debug_view.SaveDebugChart(baseUnit, "baseUnit", "baseUnit")
  599. //debug_view.SaveDebugChart(baseUnit2, "baseUnit2", "baseUnit2")
  600. //baseUnit = baseUnitList2[0]
  601. // ---------------------------------------------------------------------------------------
  602. // Src,截取的部分要小于 Base 的部分
  603. //srcUnitList, err := sub_helper.GetVADInfosFromSub(infoSrc, FrontAndEndPerSrc, 1)
  604. //if err != nil {
  605. // t.Fatal(err)
  606. //}
  607. //srcUnit := srcUnitList[0]
  608. srcUnitList2, err := sub_helper.GetVADInfoFeatureFromSub(infoSrc, FrontAndEndPerSrc, 100000, true)
  609. if err != nil {
  610. t.Fatal(err)
  611. }
  612. srcUnit := srcUnitList2[0]
  613. debug_view.SaveDebugChart(srcUnit, "srcUnit", "srcUnit")
  614. //debug_view.SaveDebugChart(srcUnit2, "srcUnit2", "srcUnit2")
  615. //srcUnit = srcUnitList2[0]
  616. // ---------------------------------------------------------------------------------------
  617. bok, got, sd, err := timelineFixer.GetOffsetTimeV2(&baseUnit, &srcUnit, nil, 0)
  618. if (err != nil) != tt.wantErr {
  619. t.Errorf("GetOffsetTimeV1() error = %v, wantErr %v", err, tt.wantErr)
  620. return
  621. }
  622. if bok == false {
  623. t.Fatal("GetOffsetTimeV2 return false")
  624. }
  625. if got > -0.2 && got < 0.2 && tt.want == 0 {
  626. // 如果 offset time > -0.2 且 < 0.2 则认为无需调整时间轴,为0
  627. } else if got > tt.want-0.1 && got < tt.want+0.1 {
  628. // 在一个正负范围内都可以接受
  629. } else {
  630. t.Errorf("GetOffsetTimeV1() got = %v, want %v", got, tt.want)
  631. }
  632. //if bok == true && got != 0 {
  633. // _, err = timelineFixer.FixSubTimeline(infoSrc, got, tt.args.srcSubFile+FixMask+infoBase.Ext)
  634. // if err != nil {
  635. // t.Fatal(err)
  636. // }
  637. //}
  638. println(fmt.Sprintf("GetOffsetTimeV2: %fs SD:%f", got, sd))
  639. })
  640. }
  641. }
  642. func TestGetOffsetTimeV2_BaseAudio(t *testing.T) {
  643. subParserHub := sub_parser_hub.NewSubParserHub(ass.NewParser(), srt.NewParser())
  644. type fields struct {
  645. fixerConfig sub_timeline_fiexer.SubTimelineFixerConfig
  646. }
  647. type args struct {
  648. audioInfo vad.AudioInfo
  649. subFilePath string
  650. }
  651. tests := []struct {
  652. name string
  653. fields fields
  654. args args
  655. want bool
  656. want1 float64
  657. want2 float64
  658. wantErr bool
  659. }{
  660. {name: "Rick and Morty - S05E10 -0 0",
  661. args: args{audioInfo: vad.AudioInfo{
  662. FileFullPath: "C:\\Tmp\\Rick and Morty - S05E10\\英_1.pcm"},
  663. subFilePath: "C:\\Tmp\\Rick and Morty - S05E10\\英_2.ass"},
  664. want: false, want1: 0,
  665. },
  666. {name: "Rick and Morty - S05E10 -- 1",
  667. args: args{audioInfo: vad.AudioInfo{
  668. FileFullPath: "C:\\Tmp\\Rick and Morty - S05E10\\英_1.pcm"},
  669. subFilePath: "C:\\Tmp\\Rick and Morty - S05E10\\Rick and Morty - S05E10 - Rickmurai Jack WEBRip-1080p.chinese(简英,zimuku).ass"},
  670. want: true, want1: -6.4,
  671. },
  672. {name: "Rick and Morty - S05E01 -- 0",
  673. args: args{audioInfo: vad.AudioInfo{
  674. FileFullPath: "C:\\Tmp\\Rick and Morty - S05E01\\未知语言_1.pcm"},
  675. subFilePath: "C:\\Tmp\\Rick and Morty - S05E01\\英_2.ass"},
  676. want: false, want1: 0,
  677. },
  678. {name: "Rick and Morty - S05E01 -- 0",
  679. args: args{audioInfo: vad.AudioInfo{
  680. FileFullPath: "C:\\Tmp\\Rick and Morty - S05E01\\未知语言_1.pcm"},
  681. subFilePath: "C:\\Tmp\\Rick and Morty - S05E01\\英_2.srt"},
  682. want: false, want1: 0,
  683. },
  684. {name: "Rick and Morty - S05E01 -- 1",
  685. args: args{audioInfo: vad.AudioInfo{
  686. FileFullPath: "C:\\Tmp\\Rick and Morty - S05E01\\未知语言_1.pcm"},
  687. subFilePath: "C:\\Tmp\\Rick and Morty - S05E01\\Rick and Morty - S05E01 - Mort Dinner Rick Andre WEBDL-1080p.chinese(简英,zimuku).ass"},
  688. want: true, want1: -6.4,
  689. },
  690. }
  691. for _, tt := range tests {
  692. t.Run(tt.name, func(t *testing.T) {
  693. s := &SubTimelineFixer{
  694. fixerConfig: tt.fields.fixerConfig,
  695. }
  696. bFind, infoSrc, err := subParserHub.DetermineFileTypeFromFile(tt.args.subFilePath)
  697. if err != nil {
  698. t.Fatal(err)
  699. }
  700. if bFind == false {
  701. t.Fatal("sub not match")
  702. }
  703. /*
  704. 这里发现一个梗,内置的英文字幕导出的时候,有可能需要合并多个 Dialogue,见
  705. internal/pkg/sub_helper/sub_helper.go 中 MergeMultiDialogue4EngSubtitle 的实现
  706. */
  707. //sub_helper.MergeMultiDialogue4EngSubtitle(infoSrc)
  708. // Src,截取的部分要小于 Base 的部分
  709. srcUnitList, err := sub_helper.GetVADInfosFromSub(infoSrc, FrontAndEndPerSrc, 1)
  710. if err != nil {
  711. t.Fatal(err)
  712. }
  713. srcUnit := srcUnitList[0]
  714. srcUnitList2, err := sub_helper.GetVADInfoFeatureFromSub(infoSrc, FrontAndEndPerSrc, 10000, true)
  715. if err != nil {
  716. t.Fatal(err)
  717. }
  718. srcUnit2 := srcUnitList2[0]
  719. audioVADInfos, err := vad.GetVADInfoFromAudio(vad.AudioInfo{
  720. FileFullPath: tt.args.audioInfo.FileFullPath,
  721. SampleRate: 16000,
  722. BitDepth: 16,
  723. }, true)
  724. if err != nil {
  725. t.Fatal(err)
  726. }
  727. f := ffmpeg_helper.NewFFMPEGHelper()
  728. bok, duration, err := f.GetAudioInfo(tt.args.audioInfo.FileFullPath)
  729. if err != nil || bok == false {
  730. t.Fatal(err)
  731. }
  732. got, got1, got2, err := s.GetOffsetTimeV2(nil, &srcUnit, audioVADInfos, duration)
  733. got, got1, got2, err = s.GetOffsetTimeV2(nil, &srcUnit2, audioVADInfos, duration)
  734. if (err != nil) != tt.wantErr {
  735. t.Errorf("GetOffsetTimeV3() error = %v, wantErr %v", err, tt.wantErr)
  736. return
  737. }
  738. debug_view.SaveDebugChartBase(audioVADInfos, "audioVADInfos", "audioVADInfos")
  739. debug_view.SaveDebugChart(srcUnit, "srcUnit", "srcUnit")
  740. debug_view.SaveDebugChart(srcUnit2, "srcUnit2", "srcUnit2")
  741. if got != tt.want {
  742. t.Errorf("GetOffsetTimeV3() got = %v, want %v", got, tt.want)
  743. }
  744. if got1 != tt.want1 {
  745. t.Errorf("GetOffsetTimeV3() got1 = %v, want %v", got1, tt.want1)
  746. }
  747. if got2 != tt.want2 {
  748. t.Errorf("GetOffsetTimeV3() got2 = %v, want %v", got2, tt.want2)
  749. }
  750. })
  751. }
  752. }