diff --git a/src/Command/KanjiExtractCommand.php b/src/Command/KanjiExtractCommand.php index a8d6f73..cc77b61 100644 --- a/src/Command/KanjiExtractCommand.php +++ b/src/Command/KanjiExtractCommand.php @@ -12,12 +12,14 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\VarExporter\VarExporter; #[AsCommand('app:extract', 'Create list recursively from path')] class KanjiExtractCommand extends Command { - public function __construct() - { + public function __construct( + private string $varBasepath, + ) { parent::__construct(); } @@ -52,15 +54,21 @@ class KanjiExtractCommand extends Command $kanjiStr = Japanese::getOnlyKanji($line); foreach (Japanese::mbIterate($kanjiStr) as $char) { if (!key_exists($char, $kanji)) { - $kanji[$char] ??= 0; + $kanji[$char] ??= []; echo $char; if (count($kanji) % 40 === 0) echo "\n"; } - $kanji[$char]++; + + if (count($kanji[$char]) < 50) { + $kanji[$char][$fileinfo->getPathname()] ??= 0; + $kanji[$char][$fileinfo->getPathname()]++; + } } } } + file_put_contents("$this->varBasepath/ebook-ref.php", '