From 87ca6a5564be7cb8bf3ab56d6925a0b4bd661c06 Mon Sep 17 00:00:00 2001 From: Dendy Faist Date: Mon, 8 Sep 2025 08:23:52 +0200 Subject: [PATCH] feat: Grey out ignored kanji in grid with special list --- data/ignored.list | 61 ++++++++++++++++++++++++++++++ src/Controller/KanjiController.php | 31 ++++++++++++++- templates/kanji/grid.html.twig | 2 +- 3 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 data/ignored.list diff --git a/data/ignored.list b/data/ignored.list new file mode 100644 index 0000000..4dc5d82 --- /dev/null +++ b/data/ignored.list @@ -0,0 +1,61 @@ +勐 +Sale como 異体字 de 猛 pero en verdad parece ser que se usa en nombre de +cuidades tailandesas? Parece que denota un tipo de templo especifico. +https://en.wikipedia.org/wiki/Mueang + +勑 +異体字 de 勅 y su 旧字体「敕」. No tiene mucho interés. + +勰 +Significa "harmonioso" pero no hay mucho en referencia de ello. +Básicamente se usa para el nombre de un pavo que hizo un libro sobre agricultura. +En ebooks sale esta persona también referenciada. + +勚 +Versión simplificada de 勩. No tiene ni uso ni referencias ni nada. + +勔 +異体字 of 勉強の勉. No se usa. No tiene interés. + +匊 +Old variant of 掬, also has the 古字 of "𦥑" . An ebook says it represent +having your hands full with rice. + +匋 +Old variant/origin? of 陶, which is 常用漢字 / 名前に使える漢字 and 3級. Seems +to kinda mean "pottery" , "clay" . It's used in 陶器[とうき]. +Not interesting on its own + +匜 +Old vase for holding water/wine. Not used aside from that. +https://en.wikipedia.org/wiki/Yi_(vessel) +REVISIT + +匦 +Simplified form of 匭. Not of interest at all. Small box or something. + +匵 +Old variant of something that isn't even used. No reason to pay attention + +匼 +Not used at all, wtf. Seems to be used in some dialects to kinda mean 蓋[ふた]. +Of no interest. + +匾 +Traditional chinese of 匾 (same code lol). Horizontal tablet to have the name +of stuff in entrances and stuff. +Traditional is 匾 and in japanese it's just 扁, wich is +一級. Of no interest for now, idk, too many characters for one concept. +https://zh.wikipedia.org/wiki/%E5%8C%BE%E9%A1%8D +REVISIT + +卌 +Means forty. Not used aside historially and not as funny as 卄, 卅 or 卆 + +卞 +Seems to be used in names of places and that's kinda it. A variant of 鞭 or +something. Not learning it for now. Of no interst. + +卟 +used in the transliteration of the names of organic compounds porphyrin 卟啉 +and porphin 卟吩. Of no use. diff --git a/src/Controller/KanjiController.php b/src/Controller/KanjiController.php index 071bea9..8aef246 100644 --- a/src/Controller/KanjiController.php +++ b/src/Controller/KanjiController.php @@ -29,6 +29,29 @@ class KanjiController extends AbstractController return "kanji/$path.html.twig"; } + /** @return array */ + public function getIgnoredList(): array + { + $path = "{$this->getParameter('kernel.project_dir')}/data/ignored.list"; + $ret = []; + + $file = fopen($path, 'r'); + while (($kanji = fgets($file)) !== false) { + $kanji = mb_trim($kanji); + + if (mb_strlen($kanji) !== 1) throw new \Exception(sprintf( + 'Kanji expected, got "%s"', + $kanji, + )); + while (($explanation = fgets($file)) !== false) { + if ($explanation === "\n") continue 2; + $ret[$kanji] = mb_trim(fgets($file)); + } + } + + return $ret; + } + /** @return array> */ private function getCharInfo(bool $force = false): array { @@ -42,6 +65,7 @@ class KanjiController extends AbstractController 'sn' => $this->anki->getKnownSnKanjiCounts(), 'sln' => $this->anki->getKnownSlnKanjiCounts(), 'unicode' => $this->anki->getUnicodeKanji(), + 'ignored' => $this->getIgnoredList(), ]; // @formatter:off @@ -103,9 +127,12 @@ class KanjiController extends AbstractController public function register(string $codepoint): Response { // Properly check it's valid (make a util?) - $char = mb_chr(Number::hexint($codepoint), 'UTF-8'); + $charStr = mb_chr(Number::hexint($codepoint), 'UTF-8'); + + $note = UnicodeNote::fromCharacter($charStr); + $terms = $this->anki->searchTerms($charStr); + $note->setTerms($terms); - $note = UnicodeNote::fromCharacter($char); $this->anki->addNote($note, UnicodeNote::DECK); return new Response(); diff --git a/templates/kanji/grid.html.twig b/templates/kanji/grid.html.twig index 71e5dc2..88feee2 100644 --- a/templates/kanji/grid.html.twig +++ b/templates/kanji/grid.html.twig @@ -42,7 +42,7 @@ .ebook { border-top: 3px solid deeppink !important; } .jimaku { border-top: 3px solid lightgray !important; } - .none { opacity: 0.40; } + .none, .ignored { opacity: 0.15; }