mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 00:27:55 +00:00
Docs: Update benchmark for anthropic/claude-opus-4.5 TEMP:0.7
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
async function processCSV(csv, config) {
|
||||
const { filterColumn, filterValue, groupBy, aggregateColumn, operation } = config;
|
||||
|
||||
const { default: Papa } = await import('https://cdn.jsdelivr.net/npm/papaparse@5/+esm');
|
||||
|
||||
const { data } = Papa.parse(csv, { header: true, skipEmptyLines: true });
|
||||
|
||||
const filtered = data.filter(row => row[filterColumn] == filterValue);
|
||||
|
||||
const groups = {};
|
||||
for (const row of filtered) {
|
||||
const key = row[groupBy];
|
||||
(groups[key] ??= []).push(row);
|
||||
}
|
||||
|
||||
const toNum = v => {
|
||||
const n = Number(v);
|
||||
return isNaN(n) ? 0 : n;
|
||||
};
|
||||
|
||||
const ops = {
|
||||
sum: rows => rows.reduce((s, r) => s + toNum(r[aggregateColumn]), 0),
|
||||
avg: rows => rows.length ? ops.sum(rows) / rows.length : 0,
|
||||
count: rows => rows.length
|
||||
};
|
||||
|
||||
return Object.entries(groups).map(([k, v]) => ({
|
||||
[groupBy]: k,
|
||||
result: ops[operation](v)
|
||||
}));
|
||||
}
|
||||
export default processCSV;
|
||||
Reference in New Issue
Block a user