2

I have a series of questions about writing code for iOS and including handwritten recognition of japanese. I am a beginner, so be gentle and assume I am stupid ...

I'd like to present a japanese word in hiragana (japanese phonetic alphabet), then have the user handwrite the appropriate kanji (chinese character). Then, this is internally compared to the correct character. Then, user gets feedback (if they were correct or not).

My questions here revolve around the handwritten input. I know normally if one uses the chinese keyboard this type of input is possible.

How can I institute something similar, without using the keyboard itself? Are there already library functions for this (I feel there must be since that input is available on the chinese keyboard)?

Also, Kanji aren't exactly the same as chinese characters. There are unique characters that japanese people invented themselves. How would I be able to include these in my handwriting recognition?

Makoto
  • 104,088
  • 27
  • 192
  • 230
Lordof Theflies
  • 301
  • 1
  • 6
  • 16
  • i should add that I have a simple notebook-like app that does the japanese handwriting recognition perfectly with it's own inputter (not the keyboard). So i know it's possible. I just don't know how they did it! that app is called HWNotes by NOWPRODUCTION if you need to see what I'm talking about. – Lordof Theflies Jun 16 '11 at 23:22

1 Answers1

3

We worked on a similar exercise back at University.

As the order of the strokes is well defined with kanji and there are only 8 (?) different strokes. Basically each Kanji is a well-ordered sequence of strokes. Like te (hand) is the sequence "The short falling backward stroke" and then twice the "left to right stroke" and finally "The long downward stroke with the little tip at the bottom". There are databases that give you this information.

Now the problem is almost reduced to identify the correct stroke. You will still run into some ambiguities where you have to take into consideration in which spatial relation some strokes are to some others.

EDIT: For stroke recognition we snapped the free hand writing to 45 degrees (Where is the little circle symbol on the keyboard?) angles, thus converting it into a sequence of vectors along one of these directions. Let's assume that direction zero is from bottom to top, direction 1 bottom right to top left, 2 from right to left and so on CCW.

Then the first stroke of te (手) would be [23]+ (as some write it falling and some horizontal) The second and third stroke would be 6+ and the last would be 4+[123] (as with the little tip, every writer uses a different direction)

This coarse snapping was actually enough for us to recognize kanjis. Maybe there are more sofisticated ways, but this simple solution managed to recognize about 90% of kanjis. It couldn't grasp only the handwriting of one professor, but the problem was that also no human except himself could read his handwriting.

EDIT2: It is important that your user "prints" the Kanji and doesn't write in calligraphy, since in calligraphy many strokes are merged into one. Like when writing a kanji with the radical of "rice field" in calligraphy, this radical morphs into something completely different. Or radicals with a lot of horizontal dashes (like the radical of "speech" iu) just become one long wriggly line.

Hyperboreus
  • 31,997
  • 9
  • 47
  • 87
  • thanks! I suppose i could write the code from scratch .... but i was hoping there were built-in iOS functions for that since it's built into the keyboard. do you know one of those databases. and do they include the length of the stroke (normalized length i suppose for the size of the box)? – Lordof Theflies Jun 17 '11 at 01:05
  • IIRC we got a stroke database from the faculty of Japanology (or was it Computer Linguistics) of Ludwig Maximilian University, Munich, Germany. If google doesn't help it might be a good idea to contact some universities with Japanology, Sinology or CL faculties. – Hyperboreus Jun 17 '11 at 14:28
  • I noticed some iOS kanji-related software seemed to contain instructions for the user to turn on their chinese character input before using the software, so I would guess they couldn't find any way to do it directly. – Bemmu Jun 17 '11 at 14:42
  • i guess I forgot to mention that I want this to work for kana as well. actually, there are some really good apps doing the recognition, i just don't know how they did it! this one is nice. http://itunes.apple.com/jp/app/id338520753?mt=8# but it says they are using a recognition engine distributed by panasonic. distributed how, i have no idea. but it does recognition better than apple's chinese one. – Lordof Theflies Jun 17 '11 at 15:24
  • i suppose i want to spend time making the app utilizing the recognition, rather than developing the recognition itself – Lordof Theflies Jun 17 '11 at 15:32
  • OK. Gesture recognition libraries (a stroke is a gesture after all) should not be that hard to find, I hope. – Hyperboreus Jun 17 '11 at 15:35