1

I currently creating a simple Japanese learning application in Ruby on Rails.

I have a Word model that needs to create a Kanji model if it contains a kanji character.

At first, I though of using Regex but after some digging, I found that in my case, I can create Range object that can capture a wide range of kanji characters

For example, "一".."時" will have a total count of 6211 letters (some of these are not even kanji letters, they're radicals).

My question is, is how do I roughly capture all standard 2136 kanji letters that Japanese learn, in a range object?

taz mazia
  • 182
  • 10
  • 2
    A `Range` has a start and an end. That means if the required letters are not defined in one range but in multiple ranges interrupted by unwanted characters then you cannot use a `Range`. Instead, you need to create an `Array` or `Set` on your own, for example, by concatenating all sub-ranges that only include the desired letters. Or you might want to consider using a gem like [`common_kanjis`](https://github.com/JuanitoFatas/common_kanjis). – spickermann Apr 08 '22 at 12:43
  • _"some of these are not even kanji letters, they're radicals"_ – so a word containing these radicals would be treated by your Kanji model – is that an actual problem? – Stefan Apr 08 '22 at 13:24
  • A Japanese word and, if I'm not wrong, any Chinese word do not contain radicals. They serve as building blocks for the kanji letters. They're not actual letters, in short. – taz mazia Apr 08 '22 at 17:11

0 Answers0