21 lines
1006 B
TypeScript
21 lines
1006 B
TypeScript
import { readFile, writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
async function compare() {
|
|
const csvContent = await readFile("measure.csv", "utf-8");
|
|
const lines = csvContent.split("\n").slice(1);
|
|
const predictions = JSON.parse(await readFile("sample/results.json", "utf-8"));
|
|
|
|
const diffMap: any = { "Oni": "oni", "Edit": "ura", "Ura": "ura" };
|
|
const comparison = predictions.map((p: any) => {
|
|
const songno = p.file.match(/(\d+)\.tja/)?.[1];
|
|
const match = lines.find(l => l.split(",")[1] === songno && l.split(",")[2] === diffMap[p.course]);
|
|
const actual = match ? parseFloat(match.split(",")[0]) : null;
|
|
return { title: p.title, actual, predicted: parseFloat(p.predicted), diff: actual ? (actual - parseFloat(p.predicted)).toFixed(2) : null };
|
|
});
|
|
|
|
await writeFile("sample/comparison.json", JSON.stringify(comparison, null, 2));
|
|
console.log("비교 완료: sample/comparison.json에 저장되었습니다.");
|
|
}
|
|
compare().catch(console.error);
|