SethClydesdale / genki-study-resources

A collection of exercises for practicing what is taught in Genki: An Integrated Course in Elementary Japanese.
https://sethclydesdale.github.io/genki-study-resources/lessons-3rd/
MIT License
753 stars 253 forks source link

Allow Kanji equivalent for various words #257

Open ryanone opened 4 months ago

ryanone commented 4 months ago

There are certain words that are frequently used in answers, and as of now, only the pure Hiragana versions are considered valid:

  1. おいしい ー 「美味しい」は使えません。「おいしい」だけは使えます。
  2. 友だち ー 「友達」は使えません。「友だち」だけは使えます。

It's been my experience that popup suggestions while typing, will show the version of the word that contains the Kanji characters. I can create a PR if you're in agreement. Thanks for making this amazing learning tool!

SethClydesdale commented 4 months ago

Hello!

You're free to make a PR to implement these variations if you like! I've already done a course of implementing support for ともだち、友達 and 友だち, before, but there is the chance I've missed some. I'll leave info on how the answer fields work below.

Normally for a single answer, the field looks like this: {答え} For two or more answers it looks like this by adding the "answer" flag on the end: {答え1|答え2|答え3|answer} (only the first two answers are visible to the user) For automating the generation of mixed kana/kanji answers we have a helper function called Genki.getAlts(). It's used in this fashion: brackets to capture a kanji in the first argument's sentence, and the kana definitions for the captured kanji in the second argument, separated by a horizontal bar.

{わたしのともだち|私の友だち|' + Genki.getAlts('{私}の{友}{達}', 'わたし|とも|だち') + 'answer}

Two visible answers, either in full kana or full kanji, and then multiple hidden sub-answers generated by Genki.getAlts(). For the above answer, it generates the following sub-answers allowing more liberal usage of kana or kanji.

私の友達
私の友だち
私のとも達
私のともだち
わたしの友達
わたしの友だち
わたしのとも達
わたしのともだち

You can take a look over this commit to get an idea of how additional kanji/kana variations are handled.