import { SentenceGenerator } from '../src/module/sentence-generator.ts'; import { writeFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = dirname(fileURLToPath(import.meta.url)); const outputPath = join(__dirname, '../data/sentence-01.json'); console.log('šŸš€ å¼€å§‹ē”Ÿęˆ1000ę”å“²ē†å„...\n'); const generator = new SentenceGenerator({ count: 1000, outputFormat: 'json', withTags: true, templateTypes: ['对比', 'å› ęžœ', '隐喻', 'åˆ¤ę–­'] }); const results = generator.generateAndOutput() as any[]; // ę·»åŠ å…ƒäæ”ęÆ const outputData = { meta: { total: results.length, generatedAt: new Date().toISOString(), generator: 'sentence-generator.ts', version: '1.0' }, sentences: results }; // 写兄文件 writeFileSync(outputPath, JSON.stringify(outputData, null, 2), 'utf-8'); console.log(`āœ… ęˆåŠŸē”Ÿęˆ ${results.length} ę”å„å­`); console.log(`šŸ“ č¾“å‡ŗåˆ°: ${outputPath}\n`); // ę‰“å°ē»Ÿč®”äæ”ęÆ console.log('šŸ“Š äø»é¢˜åˆ†åøƒē»Ÿč®”ļ¼š'); const stats = generator.getStats(); const sortedStats = Object.entries(stats) .sort(([, a], [, b]) => b - a) .slice(0, 10); sortedStats.forEach(([theme, count]) => { const bar = 'ā–ˆ'.repeat(Math.floor(count / 10)); console.log(` ${theme.padEnd(6)}: ${count.toString().padStart(4)} ${bar}`); }); console.log(`\nšŸ“‹ ęØ”ęæē±»åž‹åˆ†åøƒļ¼š`); const templateCount: Record = {}; results.forEach((s: any) => { const type = s.template.split(/[\d]/)[0] || s.template; templateCount[type] = (templateCount[type] || 0) + 1; }); Object.entries(templateCount).forEach(([type, count]) => { console.log(` ${type}: ${count} ę”`); });