chanind / hanzi-writer-data

The data used by Hanzi Writer
https://chanind.github.io/hanzi-writer
519 stars 204 forks source link

Feature request: Support Japanese Characters #2

Open gajewsk2 opened 5 years ago

gajewsk2 commented 5 years ago

Would it be possible to load the data mentioned here: https://github.com/skishore/makemeahanzi/issues/18, https://raw.githubusercontent.com/parsimonhi/animCJK/master/graphicsJa.txt into the hanzi writer data for use with the hanzi writer library.

chanind commented 5 years ago

ack I'm really sorry I somehow missed this comment! Those do look compatible with Hanzi Writer. This looks really cool! I'll see if i can put together a version of the data repo based on the JA graphics from animCJK.

chanind commented 5 years ago

Apologies for the extreme delay on this. I put a repo up with Japanese data from animCJK here: https://github.com/chanind/hanzi-writer-data-jp. You can use this in Hanzi Writer via a custom charDataLoader function, like below:

HanziWriter.create('target-div', '私', {
  width: 400,
  height: 400,
  charDataLoader: (char, onLoad, onError) => {
    fetch(`https://cdn.jsdelivr.net/npm/hanzi-writer-data-jp@0/${char}.json`)
      .then(res => res.json())
      .then(onLoad)
      .catch(onError);
  }
})

This Japanese data is limited compared to the Chinese currently due to:

I'll work on tidying this up before making an official release in HanziWriter adding first-class support for this data. I also want to double-check with animCJK that using the data this way is alright.

Anrai commented 5 years ago

Hello, author. Thank you very much for your works, It is great! but I have some problems now. Some Chinese characters do not exist in your hanzi-writer-data@2.0, May I ask if it is possible to increase? Thank you!

JhonnySalles commented 4 years ago

@Anrai

To get around this problem, I do the query on the Japanese IP first, if there is an error to load, the function HanziWriter.create executes a new call on the onLoadCharDataError but on the Chinese IP.

With that I got around the problem of not finding the character, when it doesn't find a small leg at first, but it works normally.

I believe that the correct thing would be to increase the number of characters in Japanese, but as long as it does not happen you can solve the problem.

The following example images.

image

image

chanind commented 4 years ago

This is a great idea, thanks for sharing! Hopefully we can get something like this built-in to Hanzi Writer so it's easier to work with Japanese characters without needing to do these workarounds.

JhonnySalles commented 4 years ago

Yes, it was a good change, there is only the problem of delay between loading when there is no kanji in the Japanese set. Despite this 1 or 2 second delay, everything works correctly.

From what I realized there are very few that do not exist, but studying the JLPT from 1 to 5, I noticed that there are some missing, even containing 2 thousand kanji.

I have a dictionary that works with javascript that presents popup for kanji. The name is "_kanjax_with_koohii", it has 3,000 kanji in it, you could take them into account to import Chinese kanji to Japanese.

image

image