![]() |
|
Requesting a public API to Sljfaq's kanji recognizer - Printable Version +- kanji koohii FORUM (http://forum.koohii.com) +-- Forum: Learning Japanese (http://forum.koohii.com/forum-4.html) +--- Forum: Learning resources (http://forum.koohii.com/forum-9.html) +--- Thread: Requesting a public API to Sljfaq's kanji recognizer (/thread-12314.html) |
Requesting a public API to Sljfaq's kanji recognizer - aldebrn - 2014-11-07 I think everyone here knows about kanji.sljfaq.org and it's fantastic kanji recognizer application. I frequently use it and it's never let me down, unlike iOS's traditional hanzi recognizer or even Google's Japanese IME handwriting recognizer. I really like that it has a "strict" mode which doesn't forgive mistakes in stroke order. When I noticed this a few months ago, I posted to the Sljfaq Google group asking if we could have some kind of API for it. I was thinking of embedding it in this very website, Anki, everywhere that people practice writing kanji. Who knows what someone could build using it. Edit: bunch of useless embarrassing info removed. I put together a mock-up of how this could work: https://gist.github.com/fasiha/546ff61f60541c84d9c8 (with pictures!) It works by embedding iframes in Anki cards, so that your Anki card loads an external website which can send data back to Anki, all through a standard, cross-platform browser technique called Web Messaging. This is demonstrated with a static webpage containing a bunch of kanji: you highlight some text in the embedded page, click a button in Anki, and the inner page's selected text shows up as the answer in Anki. It also shows what it could look like with sljfaq's kanji recgonizer, which would need some Javascript to make this work. This technique will work on Ankiweb in your browser, and should work in AnkiMobile as well, because the recognizer is mobile-friendly. If you like what you see in the screenshots, and if you can vouch for the approach's technical correctness (all the source code is in the writeup), please post to the sljfaq Google group saying you want the awesome kanji.sljfaq.org in your Anki. Requesting a public API to Sljfaq's kanji recognizer - toshiromiballza - 2014-11-07 Maybe these three topics will help you develop something on your own? Edit: fourth topic. Requesting a public API to Sljfaq's kanji recognizer - aldebrn - 2014-11-12 toshiromiballza Wrote:Maybe these three topics will help you develop something on your own?Ok, good to know, if the following (read below) doesn't work out, maybe we can go this route, though it's so much more work than iframe. The developer asked to see my iframe solution work with qhanzi, his Chinese recognition website, for which he has made an embeddable solution available. It works pretty well: you can see screenshots and I made a public shared Anki deck that basically contains just a couple of random cloze-deleted notes, but with this hanzi recognizer built-in. If you download this deck and review a card from it, you'll see the iframe containing qhanzi beneath the input textfield. If you draw a character in it and click on one of the matches, it'll show up in Anki's input field! I've asked that the kanji.sljfaq.org's feature of *disabling* look-ahead, i.e., requiring correct stroke numbers and stroke order, be retained in the kanji version, since I think most people wanting to practice writing inside Anki will want to practice stroke order. (Otherwise, if you just want to get the kanji input, use Google IME which has flexible handwriting recognition.) Looks like we might be getting this soon! Though apparently I'll be the only one using it ![]() Edit: forgot to mention: the Ankiweb website doesn't support typed answer checking! (I was incredulous but the Anki guys confirmed this .) So it will be limited to Anki desktop. Maybe AnkiMobile?
Requesting a public API to Sljfaq's kanji recognizer - RawToast - 2014-11-13 aldebrn Wrote:I've asked that the kanji.sljfaq.org's feature of *disabling* look-ahead, i.e., requiring correct stroke numbers and stroke order, be retained in the kanji version, since I think most people wanting to practice writing inside Anki will want to practice stroke order. (Otherwise, if you just want to get the kanji input, use Google IME which has flexible handwriting recognition.)From the code it on qhanzi/kanji.sljfaq it looks like if you were to use the javascript on qhanzi it would already supports this. Looking at the qhanzi code, to remove the list of kanji shown at the bottom all you'd have to do is modify the following in in draw.js and remove the call to this.show_kanji_list() DrawKanji.prototype.result_callback = function (reply) { this.reply = parse_json (reply); if (! this.reply) return; if (this.save_my_input) { if (this.has_local_storage) { localStorage.reply = reply; } else { set_cookie ("server_input_id="+this.reply.input_id); } } this.show_kanji_list (); <--- me } There's another call to remove in the 'back'/'remove last' function Then create a button and use a javascript 'onclick' event to call show_kanji_list() when the user presses the button. That will still show results with the wrong stroke order, but it atleast removes the 'hints' until the user is ready. The lookahead and stroke order seems to be set using the 'key' value in draw.js. It should be automatically set to 'H' which according to the javascript on http://kanji.sljfaq.org/ should honour stroke order and have lookahead disabled. That looks to be the case, I get different results on the kanji.sljfaq site to qhanzi when I turn on look ahead. To enable lookahead set the key to a "HL" and to ignore stroke order use 'h' Requesting a public API to Sljfaq's kanji recognizer - aldebrn - 2014-11-13 Thanks for that! I didn't think about just ripping the JS & HTML and putting them straight in Anki cards Ben Bullock can't be against that since he's making the underlying interface available, per @toshiromiballza's post.Without looking into it in much detail, is it possible to modify qhanzi.com's code to hit the kanji database instead of the Chinese one? Also, do you think it's a good idea to hide the suggestions until the user clicks "show me what matches" when they're done? I think most people like to keep up a quick pace when doing Anki reps, and would prefer to minimize the number of clicks they have to make, so I was thinking it would be ok to keep updating the suggestions list and let the user click on one when they're done. The actual kanji shouldn't appear until they're done with the strict mode, since # of strokes has to match: so until they're done, they will just be seeing random kanji that are very unlikely to be what they're looking for. |