Libraryless. Click here for Pure Java version (8514L/59K/201K).
1 | !752 |
2 | |
3 | concepts. |
4 | |
5 | concept Example {
|
6 | BWImage image; |
7 | S imageMD5; |
8 | S text; |
9 | |
10 | // new fields in this program: |
11 | BWImage visualizedSplit; |
12 | bool countMatch; |
13 | } |
14 | |
15 | concept Theory {
|
16 | new Ref<Example> fromExample; |
17 | BWImage image; |
18 | S imageMD5; |
19 | S text; |
20 | } |
21 | |
22 | p {
|
23 | loadConceptsFrom("#1006005");
|
24 | Concepts in = mainConcepts; |
25 | |
26 | JTable table = showConceptsTable(Example); |
27 | setFrameTitle(table, "Theories"); |
28 | |
29 | for (Example e : in.list(Example)) {
|
30 | L<Rect> rects = horizontalAutoSplit2ThenAutoCrop(e.image); |
31 | cset(e, visualizedSplit := new BWImage(mergeImagePartsHorizontally(e.image.toRGB(), rects))); |
32 | S text = e.text.replace(" ", "");
|
33 | cset(e, countMatch := l(rects) == l(text)); |
34 | if (!e.countMatch) |
35 | print("Bad number of characters: " + l(rects) + " vs " + l(text));
|
36 | else {
|
37 | for i over rects: {
|
38 | BWImage cImg = e.image.clip(rects.get(i)); |
39 | cnew(Theory, fromExample := e, |
40 | image := cImg, |
41 | imageMD5 := md5OfBWImage(cImg), |
42 | text := substring(text, i, i+1)); |
43 | } |
44 | print("Made " + l(rects) + " theories");
|
45 | } |
46 | } |
47 | } |
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: | 774 / 953 |
| Referenced in: | [show references] |