@pls-compile-owo/fisheye 0.8.2 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,3 +52,32 @@ for (const { file, data } of fixtures) {
52
52
  for (let i = 1; i < r.times.length; i++) assert.ok(r.times[i] > r.times[i - 1])
53
53
  })
54
54
  }
55
+
56
+ // ── 广告段真值评估(人工标注的广告段 vs 检测结果)────────────────────────
57
+ const adTruthDir = path.join(path.dirname(fileURLToPath(import.meta.url)), 'golden', 'ad-truth')
58
+ const adTruthFiles = fs.existsSync(adTruthDir) ? fs.readdirSync(adTruthDir).filter((f) => f.endsWith('.json')) : []
59
+
60
+ test('广告真值样本存在', () => {
61
+ assert.ok(adTruthFiles.length >= 1, '至少 1 条人工标注的广告真值')
62
+ })
63
+
64
+ for (const file of adTruthFiles) {
65
+ const data = JSON.parse(fs.readFileSync(path.join(adTruthDir, file), 'utf8'))
66
+ test(`${data.bvid}(${String(data.title).slice(0, 20)}):广告段检测覆盖真值`, () => {
67
+ const segs = detectAdSegments(data.danmaku, data.duration)
68
+ let bestCover = 0
69
+ for (const truth of data.truthAdSegments) {
70
+ for (const s of segs) {
71
+ const overlap = Math.max(0, Math.min(s.to, truth.to) - Math.max(s.from, truth.from))
72
+ bestCover = Math.max(bestCover, overlap / Math.max(1, truth.to - truth.from))
73
+ }
74
+ }
75
+ assert.ok(bestCover >= 0.8, `至少覆盖真值广告段的 80%(实际 ${(bestCover * 100).toFixed(0)}%)`)
76
+ // 无片头/片尾低置信度段(片头片尾弹幕少是正常现象)
77
+ for (const s of segs) {
78
+ if (s.confidence === 'low') {
79
+ assert.ok(s.from >= 60 && s.to <= data.duration - 60, `低置信度段不应出现在片头/片尾:${s.ts}`)
80
+ }
81
+ }
82
+ })
83
+ }