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

34
LINES

< > BotCompany Repo | #1006260 // ocr_parseGlyphs - see: ocr_escapeMeaning

JavaX fragment (include)

1  
// Elements returned are still escaped
2  
// " " is returned as a glyph
3  
static L<S> ocr_parseGlyphs(S s) {
4  
  new L<S> l;
5  
  for i over s:
6  
    if (s.charAt(i) == '\\' && i+1 < l(s)) { // parse escaped character
7  
      l.add(substring(s, i, i+2));
8  
      ++i;
9  
    } else if (s.charAt(i) == '[') { // parse group
10  
      int j = i+1;
11  
      new StringBuilder buf;
12  
      while (j < l(s) && s.charAt(j) != ']') {
13  
        if (s.charAt(j) == '\\' && j+1 < l(s))
14  
          buf.append(s.charAt(j++));
15  
        buf.append(s.charAt(j++));
16  
      }
17  
      l.add(str(buf));
18  
      i = j;
19  
    } else if (s.charAt(i) == '{') { // parse symbol
20  
      int j = i;
21  
      new StringBuilder buf;
22  
      while (j < l(s) && s.charAt(j) != '}') {
23  
        if (s.charAt(j) == '\\' && j+1 < l(s))
24  
          buf.append(s.charAt(j++));
25  
        buf.append(s.charAt(j++));
26  
      }
27  
      if (j < l(s))
28  
        buf.append(s.charAt(j));
29  
      l.add(str(buf));
30  
      i = j;
31  
    } else
32  
      l.add(substring(s, i, i+1));
33  
  ret l;
34  
}

Author comment

Began life as a copy of #1006254

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: #1006260
Snippet name: ocr_parseGlyphs - see: ocr_escapeMeaning
Eternal ID of this version: #1006260/1
Text MD5: 7c9692dbec7bb9f5d5caea38e8522501
Author: stefan
Category: javax / ocr
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-26 01:29:36
Source code size: 1013 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 419 / 445
Referenced in: [show references]