genki-study-resources icon indicating copy to clipboard operation
genki-study-resources copied to clipboard

Allow Kanji equivalent for various words

Open ryanone opened this issue 11 months ago • 1 comments

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!

ryanone avatar Mar 07 '24 07:03 ryanone

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.

SethClydesdale avatar Mar 07 '24 20:03 SethClydesdale