Integrate the reviewed 2.0 PRs and local fixes from 03136853. Preserve the verified subtitle behavior and model/runtime corrections. Keep the numeric Beta tag compatible with released clients while exposing the date as application build metadata. Co-authored-by: DepengWang <2818245+DepengWang@users.noreply.github.com> Co-authored-by: HKLHaoBin <we3q@qq.com> Co-authored-by: Nahida <1139500183@qq.com> Co-authored-by: TRIP <1933142963@qq.com> Co-authored-by: chyuwei <weichangyuwcy@gmail.com> Co-authored-by: leonoxo <leonoxo@gmail.com> Co-authored-by: tayir <arnoldincredible@126.com>
24 lines
912 B
JavaScript
24 lines
912 B
JavaScript
import fs from 'node:fs';
|
|
|
|
const source = process.argv[2];
|
|
const output = process.argv[3];
|
|
if (!source || !output) throw new Error('usage: node generate-stroke-frequency.mjs SOURCE OUTPUT');
|
|
|
|
const rows = fs.readFileSync(source, 'utf8').split(/\r?\n/);
|
|
const best = new Map();
|
|
for (const row of rows) {
|
|
const [character, rawWeight] = row.split('\t');
|
|
const weight = Number(rawWeight);
|
|
if (!character || !Number.isFinite(weight) || [...character].length !== 1) continue;
|
|
if (!/^[㐀-鿿]$/.test(character)) continue;
|
|
const previous = best.get(character);
|
|
if (!previous || weight > previous) best.set(character, weight);
|
|
}
|
|
|
|
const result = [...best.entries()]
|
|
.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
|
|
.map(([character, weight]) => `${character}\t${weight}`)
|
|
.join('\n') + '\n';
|
|
fs.writeFileSync(output, result, 'utf8');
|
|
console.log(`generated ${best.size} character frequencies`);
|