Datasets:
Download code/evaluation-code/v0.2-0c2690ae/apps/console/web/src/format.ts from VEHwang/cocogni4d: direct link, hf CLI and curl.
- Browser
- Download file 794 Bytes
-
https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/v0.2-0c2690ae/apps/console/web/src/format.ts
- Command line
-
hf download hf://datasets/VEHwang/cocogni4d/code/evaluation-code/v0.2-0c2690ae/apps/console/web/src/format.ts
-
curl -L -o format.ts https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/v0.2-0c2690ae/apps/console/web/src/format.ts
794 Bytes
| import type {MetricUnits, ReviewProgress} from './contract.ts'; | |
| export function metric(value: number | null | undefined, field: string, units: MetricUnits): string { | |
| if (value == null) return '本段还没有'; | |
| const unit = units[field]; | |
| if (!Number.isFinite(value) || !unit) throw Error('指标数值或单位缺失:' + field); | |
| if (unit === 'count') { | |
| if (!Number.isInteger(value)) throw Error('计数不是整数:' + field); | |
| return String(value); | |
| } | |
| return unit === 'ratio' ? (value * 100).toFixed(1) + '%' : value.toFixed(1) + ' s'; | |
| } | |
| export function populationText(p: ReviewProgress): string { | |
| if (p.total !== p.generated + p.not_generated) throw Error('批次分母不一致'); | |
| return `${p.total} 格:${p.generated} 生成、${p.not_generated} 未生成`; | |
| } | |