!752 concepts. concept Example { BWImage image; S imageMD5; S text; // new fields in this program: L rects; BWImage visualizedSplit; S guessedText; //bool countMatch; } static MultiMap learnedChars; p { loadConceptsFrom("#1006005"); Concepts in = mainConcepts; for (Example e : in.list(Example)) e.rects = horizontalAutoSplit2ThenAutoCrop(e.image); showConceptsTable_dropFields.set(ll("imageMD5")); final JTable table = showConceptsTable(Example); setFrameTitle(table, "Recognizing texts"); tablePopupMenu(table, voidfunc(JPopupMenu menu, int row) { final Example e = (Example) getConcept((long) getTableCell(table, row, 0)); addMenuItem(menu, "Copy single character to clipboard...", r { final JTextField tf = jTextField("1"); showForm("Character index (1 to " + l(e.rects) + ")", tf, r { copyBWImageToClipboard(e.image.clip(e.rects.get(parseInt(trim(tf.getText()))-1))); }); }); }); learnedChars = getLearnedChars(); for (Example e : in.list(Example)) guess(e); for (Example e : in.list(Example)) { // first, auto-split cset(e, visualizedSplit := new BWImage(mergeImagePartsHorizontally(e.image.toRGB(), e.rects))); new StringBuilder buf; for (Rect r : e.rects) { BWImage cImg = e.image.clip(r); S md5 = md5OfBWImage(cImg); L l = learnedChars.get(md5); S c = or(first(l), "?"); buf.append(c); } cset(e, guessedText := str(buf)); } } svoid guess(Example e) { if (nempty(e.text)) learnedChars.setPut(e.imageMD5, e.text); L rects = horizontalAutoSplit2ThenAutoCrop(e.image); S text = e.text.replace(" ", ""); bool countMatch = l(rects) == l(text); if (!countMatch) ret; print("Guessing " + text); for i over rects: { Rect r = rects.get(i); BWImage cImg = e.image.clip(r); S md5 = md5OfBWImage(cImg); learnedChars.setPut(md5, substring(text, i, 1)); } }