Download src/algorithm/DemographicsPieBySocialGroup.ts from nolual/majic: direct link, hf CLI and curl.
- Browser
- Download file 599 Bytes
-
https://huggingface.co/nolual/majic/resolve/main/src/algorithm/DemographicsPieBySocialGroup.ts
- Command line
-
hf download hf://nolual/majic/src/algorithm/DemographicsPieBySocialGroup.ts
-
curl -L -o DemographicsPieBySocialGroup.ts https://huggingface.co/nolual/majic/resolve/main/src/algorithm/DemographicsPieBySocialGroup.ts
599 Bytes
| export interface SummaryItemSocial { | |
| label: string; | |
| usage: number; | |
| } | |
| export function summarizeSocialGroups(data: any[]): SummaryItemSocial[] { | |
| const summary: { [key: string]: number } = {}; | |
| data.forEach((item) => { | |
| const socialGroup = item.social_group; | |
| const percentage = item.percentage; | |
| summary[socialGroup] = (summary[socialGroup] || 0) + percentage; | |
| }); | |
| const summaryArray: SummaryItemSocial[] = []; | |
| for (const socialGroup in summary) { | |
| summaryArray.push({ | |
| label: `${socialGroup}`, | |
| usage: summary[socialGroup], | |
| }); | |
| } | |
| return summaryArray; | |
| } | |