Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

47
LINES

< > BotCompany Repo | #1006062 // Learn to read - make theories

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (8514L/59K/201K).

!752

concepts.

concept Example {
  BWImage image;
  S imageMD5;
  S text;
  
  // new fields in this program:
  BWImage visualizedSplit;
  bool countMatch;
}

concept Theory {
  new Ref<Example> fromExample;
  BWImage image;
  S imageMD5;
  S text;
}

p {
  loadConceptsFrom("#1006005");
  Concepts in = mainConcepts;
  
  JTable table = showConceptsTable(Example);
  setFrameTitle(table, "Theories");
  
  for (Example e : in.list(Example)) {
    L<Rect> rects = horizontalAutoSplit2ThenAutoCrop(e.image);
    cset(e, visualizedSplit := new BWImage(mergeImagePartsHorizontally(e.image.toRGB(), rects)));
    S text = e.text.replace(" ", "");
    cset(e, countMatch := l(rects) == l(text));
    if (!e.countMatch)
      print("Bad number of characters: " + l(rects) + " vs " + l(text));
    else {
      for i over rects: {
        BWImage cImg = e.image.clip(rects.get(i));
        cnew(Theory, fromExample := e,
          image := cImg,
          imageMD5 := md5OfBWImage(cImg),
          text := substring(text, i, i+1));
      }
      print("Made " + l(rects) + " theories");
    }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1006062
Snippet name: Learn to read - make theories
Eternal ID of this version: #1006062/1
Text MD5: 6d922184386708e13c964d6c11304e1d
Transpilation MD5: 5ff2b53ac467ce2f12e41f38c4c612f0
Author: stefan
Category: javax / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-18 00:33:10
Source code size: 1141 bytes / 47 lines
Pitched / IR pitched: No / No
Views / Downloads: 545 / 661
Referenced in: [show references]