debug_cases.js
1.57 KB
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
38
39
const path = require('path');
const fs = require('fs');
const DIGEST_DIR = path.resolve('..', 'digest');
function loadJsonl(p) {
const text = fs.existsSync(p) ? fs.readFileSync(p, 'utf-8') : '';
return text.split('\n').map(l => l.trim()).filter(Boolean).map((l, idx) => {
try { return { ...JSON.parse(l), _lineIdx: idx }; } catch { return null; }
}).filter(Boolean);
}
const trainCases = loadJsonl(path.join(DIGEST_DIR, 'train.jsonl'));
const testCases = loadJsonl(path.join(DIGEST_DIR, 'test.jsonl'));
function classifyCase(record, useInput) {
const raw = useInput ? ((record.input || {}).raw_record || {}) : (record.raw_data || {});
const hasIcon = !!(raw.icon || raw.small_icon_desc || raw.icon_desc);
const isNewOrHot = raw.label_name === '新' || raw.label_name === '热';
const hasFlagDesc = !!raw.flag_desc;
const isTopic = raw.topic_flag === 1 || raw.topic_flag === true;
if ((hasIcon || isNewOrHot) && !hasFlagDesc) return 'type_a';
if (hasFlagDesc && !hasIcon && !isNewOrHot) return 'type_c';
if (hasFlagDesc && (hasIcon || isNewOrHot)) return 'type_ac';
if (isTopic && !hasIcon && !isNewOrHot && !hasFlagDesc) return 'type_b';
return 'type_d';
}
const allCases = [...trainCases, ...testCases];
console.log('Total cases:', allCases.length);
const types1 = {};
const types2 = {};
for (const c of allCases) {
types1[classifyCase(c, false)] = (types1[classifyCase(c, false)] || 0) + 1;
types2[classifyCase(c, true)] = (types2[classifyCase(c, true)] || 0) + 1;
}
console.log('Types from raw_data:', types1);
console.log('Types from input.raw_record:', types2);