Compare commits

..

No commits in common. "e3064a3ace7e37da5c15d3711d494cf1348f766b" and "73e64f534dd65db608a9adde70fbecdb5d0124f4" have entirely different histories.

2 changed files with 38 additions and 27 deletions

View File

@ -58,25 +58,10 @@ class CreateProductionCommand extends Command
protected function configure(): void
{
$this
->addArgument('count', InputArgument::OPTIONAL, 'Amount of cards to make', 1);
//->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
;
}
protected function createProductionNoteFromTerm(Term $term): void
{
$noteIds = $this->ankiService->findNotesIds(sprintf(
'"SentKanji:*%s*" "note:%s"',
$term->getKanji(),
SentenceNote::MODEL_NAME,
));
$sNote = $this->ankiService->getNote($noteIds[array_key_last($noteIds)]);
$newSlNote = SentenceListeningNote::fromNote($sNote, $term);
if (!$this->ankiService->addNote($newSlNote, 'production')) {
throw new \Exception('Failed to add note!');
}
//$this
// ->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
// ->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
//;
}
protected function execute(InputInterface $input, OutputInterface $output): int
@ -157,6 +142,7 @@ class CreateProductionCommand extends Command
// return strlen($b) <=> strlen($a); // ascending order
//});
printf('Rating terms...');
foreach ($knownTerms as $term) {
$termKanji = self::getOnlyKanji($term->getKanji());
@ -194,14 +180,11 @@ class CreateProductionCommand extends Command
}
printf(" OK\n");
$theChosenTerm = null;
arsort($termCounts);
printf("\n");
$newNotesCount = intval($input->getArgument('count'));
foreach ($termCounts as $term => $count) {
if ($newNotesCount <= 0) break;
$theChosenTerm = $knownTerms[$term];
$termKanji = self::getOnlyKanji($term);
printf("%s: %d\n", $term, $count);
@ -211,10 +194,23 @@ class CreateProductionCommand extends Command
printf(" - %s: %0.2f\n", $iKanji, $knownKanji[$iKanji] / $len);
}
$this->createProductionNoteFromTerm($knownTerms[$term]);
$newNotesCount -= 1;
printf("\n");
break;
};
$noteIds = $this->ankiService->findNotesIds(sprintf(
//'VocabKanji:*%s* "note:%s"',
'*%s* "note:%s"',
$theChosenTerm->getKanji(),
SentenceNote::MODEL_NAME,
));
$theChosenNote = $this->ankiService->getNote($noteIds[array_key_last($noteIds)]);
$newSlNote = SentenceListeningNote::fromNote($theChosenNote, $theChosenTerm);
if (!$this->ankiService->addNote($newSlNote, 'production')) {
throw new \Exception('Failed to add note!');
}
printf(
<<<FMNT
total: %d cards
@ -226,6 +222,21 @@ class CreateProductionCommand extends Command
memory_get_usage() / 1024 / 1024,
);
//dd($kanjiNotes);
//$io = new SymfonyStyle($input, $output);
//$arg1 = $input->getArgument('arg1');
//if ($arg1) {
// $io->note(sprintf('You passed an argument: %s', $arg1));
//}
//if ($input->getOption('option1')) {
// // ...
//}
//$io->success('You have a new command! Now make it your own! Pass --help to see your options.');
return Command::SUCCESS;
}
}

View File

@ -56,7 +56,7 @@ class AnkiService
public function getAllSentenceListeningNoteIds(): array
{
$query = sprintf(
'"note:%s"',
'"note:%s" -is:suspended',
SentenceListeningNote::MODEL_NAME,
);