Compare commits
No commits in common. "e3064a3ace7e37da5c15d3711d494cf1348f766b" and "73e64f534dd65db608a9adde70fbecdb5d0124f4" have entirely different histories.
e3064a3ace
...
73e64f534d
|
@ -58,25 +58,10 @@ class CreateProductionCommand extends Command
|
||||||
|
|
||||||
protected function configure(): void
|
protected function configure(): void
|
||||||
{
|
{
|
||||||
$this
|
//$this
|
||||||
->addArgument('count', InputArgument::OPTIONAL, 'Amount of cards to make', 1);
|
// ->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
|
||||||
// ->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
|
// ->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!');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
@ -157,6 +142,7 @@ class CreateProductionCommand extends Command
|
||||||
// return strlen($b) <=> strlen($a); // ascending order
|
// return strlen($b) <=> strlen($a); // ascending order
|
||||||
//});
|
//});
|
||||||
|
|
||||||
|
|
||||||
printf('Rating terms...');
|
printf('Rating terms...');
|
||||||
foreach ($knownTerms as $term) {
|
foreach ($knownTerms as $term) {
|
||||||
$termKanji = self::getOnlyKanji($term->getKanji());
|
$termKanji = self::getOnlyKanji($term->getKanji());
|
||||||
|
@ -194,14 +180,11 @@ class CreateProductionCommand extends Command
|
||||||
}
|
}
|
||||||
printf(" OK\n");
|
printf(" OK\n");
|
||||||
|
|
||||||
|
$theChosenTerm = null;
|
||||||
arsort($termCounts);
|
arsort($termCounts);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
$newNotesCount = intval($input->getArgument('count'));
|
|
||||||
|
|
||||||
foreach ($termCounts as $term => $count) {
|
foreach ($termCounts as $term => $count) {
|
||||||
if ($newNotesCount <= 0) break;
|
$theChosenTerm = $knownTerms[$term];
|
||||||
|
|
||||||
$termKanji = self::getOnlyKanji($term);
|
$termKanji = self::getOnlyKanji($term);
|
||||||
printf("%s: %d\n", $term, $count);
|
printf("%s: %d\n", $term, $count);
|
||||||
|
|
||||||
|
@ -211,10 +194,23 @@ class CreateProductionCommand extends Command
|
||||||
printf(" - %s: %0.2f\n", $iKanji, $knownKanji[$iKanji] / $len);
|
printf(" - %s: %0.2f\n", $iKanji, $knownKanji[$iKanji] / $len);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->createProductionNoteFromTerm($knownTerms[$term]);
|
printf("\n");
|
||||||
$newNotesCount -= 1;
|
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(
|
printf(
|
||||||
<<<FMNT
|
<<<FMNT
|
||||||
total: %d cards
|
total: %d cards
|
||||||
|
@ -226,6 +222,21 @@ class CreateProductionCommand extends Command
|
||||||
memory_get_usage() / 1024 / 1024,
|
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;
|
return Command::SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ class AnkiService
|
||||||
public function getAllSentenceListeningNoteIds(): array
|
public function getAllSentenceListeningNoteIds(): array
|
||||||
{
|
{
|
||||||
$query = sprintf(
|
$query = sprintf(
|
||||||
'"note:%s"',
|
'"note:%s" -is:suspended',
|
||||||
SentenceListeningNote::MODEL_NAME,
|
SentenceListeningNote::MODEL_NAME,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue