This commit is contained in:
2026-01-10 00:59:25 +08:00
parent 9da3d14752
commit 92ef98ce9b
27 changed files with 31787 additions and 175 deletions

View File

@@ -0,0 +1,57 @@
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<string, number> = {};
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}`);
});