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

59
LINES

< > BotCompany Repo | #1006103 // Simple Recognizer (dev.)

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

Libraryless. Click here for Pure Java version (2144L/15K/46K).

1  
!752
2  
3  
sS info = [[
4  
The images "9176714c9a935fc91e14595dbb3adddf 35731666e72dd0c9448f616ff3a7464a da9bc5a24bd503e898f69ad43bb9b92e" are the characters "yet".
5  
The images "412f9e0f8e177817a4fa285415c5a13f 386b289407599f31e3a7c57c3adb2587 6cd2a2284a5a6fda3a7cad3e3a048671 b0c47c014d665ec5b658f510c258dc47 b273ff598fe6afa04cfed9f9e8fb4109" are the grouped characters "[Ob]ject".
6  
//The image abcd12 is the character "a"
7  
//The image abcd34 is the characters "abc"
8  
//The image abcd34 can be the character "I" or "l"
9  
]];
10  
11  
sclass GlyphInfo {
12  
  S meaning;
13  
  bool multi; // multiple meanings seen
14  
}
15  
16  
// key = md5
17  
static new Map<S, GlyphInfo> glyphInfos;
18  
19  
p {
20  
  new Matches m;
21  
  for (S s : toLinesFullTrim(info)) {
22  
    if "the images * are the characters *" {
23  
      L<S> md5s = splitAtSpace($1);
24  
      L<S> characters = eachCharAsString($2);
25  
      saveMeanings(md5s, characters);
26  
    } else if "the images * are the grouped characters *" {
27  
      L<S> md5s = splitAtSpace($1);
28  
      L<S> characters = ungroupCharacters($2);
29  
      saveMeanings(md5s, characters);
30  
    } else if (nempty(javaTokC(s))) {
31  
      print("huh? " + s);
32  
    }
33  
  }
34  
  psl(glyphInfos);
35  
}
36  
37  
svoid saveMeaning(S md5, S meaning) {
38  
  GlyphInfo info = getGlyphInfo(md5);
39  
  if (info.multi) ret;
40  
  if (hasDifferent(info.meaning, meaning)) {
41  
    info.meaning = null;
42  
    info.multi = true;
43  
    print("multi");
44  
  } else
45  
    info.meaning = meaning;
46  
}
47  
48  
static GlyphInfo getGlyphInfo(S md5) {
49  
  GlyphInfo info = glyphInfos.get(md5);
50  
  if (info == null)
51  
    glyphInfos.put(md5, info = new GlyphInfo);
52  
  ret info;
53  
}
54  
55  
svoid saveMeanings(L<S> md5s, L<S> characters) {
56  
  if (l(md5s) != l(characters)) { print("huh?"); ret; }
57  
  for i over md5s:
58  
    saveMeaning(md5s.get(i), characters.get(i));
59  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006103
Snippet name: Simple Recognizer (dev.)
Eternal ID of this version: #1006103/1
Text MD5: ee1a06fef402dffab6e22fe3e7b12b4b
Transpilation MD5: 5877c3b68291c00f31c0ad4fae99b3b9
Author: stefan
Category: javax / ocr
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-18 12:33:27
Source code size: 1789 bytes / 59 lines
Pitched / IR pitched: No / No
Views / Downloads: 465 / 532
Referenced in: [show references]