mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 00:27:55 +00:00
Docs: Update benchmark for openrouter/bert-nebulon-alpha
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
const processCSV = async (csvData, config) => {
|
||||
const { parse } = await import('https://cdn.skypack.dev/papaparse@5.3.0')
|
||||
const { filterColumn, filterValue, groupBy, aggregateColumn, operation } = config
|
||||
const { data } = parse(csvData, { header: true })
|
||||
|
||||
const filtered = data.filter(row => row[filterColumn] == filterValue)
|
||||
const groups = filtered.reduce((acc, row) => {
|
||||
const key = row[groupBy]
|
||||
if (!acc[key]) acc[key] = []
|
||||
acc[key].push(row)
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
return Object.entries(groups).map(([groupValue, rows]) => {
|
||||
const numbers = rows.map(row => +row[aggregateColumn] || 0)
|
||||
let result
|
||||
|
||||
if (operation === 'sum') result = numbers.reduce((a, b) => a + b, 0)
|
||||
if (operation === 'avg') result = numbers.reduce((a, b) => a + b, 0) / numbers.length
|
||||
if (operation === 'count') result = numbers.length
|
||||
|
||||
return { [groupBy]: groupValue, result }
|
||||
})
|
||||
}
|
||||
export default processCSV;
|
||||
Reference in New Issue
Block a user