.
This commit is contained in:
@@ -1,16 +1,23 @@
|
||||
import { parseTja } from './parse';
|
||||
import { factorize } from './factorize';
|
||||
import { readdirSync, readFileSync, writeFileSync, existsSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { readdirSync, readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
|
||||
import { join, dirname } from 'path';
|
||||
import iconv from 'iconv-lite';
|
||||
|
||||
const [,, workingDir, dataDir] = process.argv;
|
||||
|
||||
if (existsSync(join(workingDir, 'features.json'))) {
|
||||
console.log('features.json already exists. Skipping extraction.');
|
||||
const featurePath = join(workingDir, 'factors.json');
|
||||
|
||||
if (existsSync(featurePath)) {
|
||||
console.log('factors.json already exists. Skipping extraction.');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// 작업 디렉토리 존재 확인 및 생성
|
||||
if (!existsSync(workingDir)) {
|
||||
mkdirSync(workingDir, { recursive: true });
|
||||
}
|
||||
|
||||
const tjaDir = join(dataDir, 'tja');
|
||||
const results: any[] = [];
|
||||
|
||||
@@ -38,5 +45,5 @@ for (const file of readdirSync(tjaDir)) {
|
||||
results.push({ songno, diff: diff === 'oni' ? 'oni' : 'ura', ...factors });
|
||||
}
|
||||
}
|
||||
writeFileSync(join(workingDir, 'features.json'), JSON.stringify(results, null, 2));
|
||||
console.log(`Features extracted to ${workingDir}/features.json`);
|
||||
writeFileSync(featurePath, JSON.stringify(results, null, 2));
|
||||
console.log(`Features extracted to ${featurePath}`);
|
||||
|
||||
Reference in New Issue
Block a user