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

41
LINES

< > BotCompany Repo | #1011762 // webs_readTripleFile

JavaX fragment (include)

1  
static L<Web> webs_readTripleFile(File f) {
2  
  // parallel isn't even faster
3  
  //if (hasMultipleCores()) ret webs_readTripleFile_parallel(f);
4  
  
5  
  if (!f.exists()) ret ll();
6  
  Iterator<S> it = linesFromFile(f);
7  
  //L<S> names = (L) unstructure(it.next());
8  
  new L<S> names;
9  
  while (it.hasNext()) {
10  
    S s = trim(it.next());
11  
    if (empty(s)) break;
12  
    names.add(unquote(s));
13  
  }
14  
  
15  
  new L<Web> webs;
16  
  while (it.hasNext()) {
17  
    S s = it.next();
18  
    pcall {
19  
      addIfNotNull(webs, webs_readTripleFile_line(s, names));
20  
    }
21  
  }
22  
  ret webs;
23  
}
24  
25  
static Web webs_readTripleFile_line(S s, L<S> names) {
26  
  // S moreInfo = quote(unnull(web.globalID)) + " " + quote(unnull(web.title)) + " " + quote(unnull(web.source)) + " " + (web.unverified ? "u" : "v") + " " + web.created;
27  
  L<S> l = javaTokC(s);
28  
  if (l(l) == 8) {
29  
    Web web = webFromTriple(
30  
      names.get(parseInt(first(l))), 
31  
      names.get(parseInt(second(l))),
32  
      names.get(parseInt(third(l))));
33  
    web.globalID = unquote(l.get(3));
34  
    web.title = unquote(l.get(4));
35  
    web.source = unquote(l.get(5));
36  
    web.unverified = !eq(l.get(6), "v");
37  
    web.created = parseLong(l.get(7));
38  
    ret web_intern(web);
39  
  }
40  
  null;
41  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1011762
Snippet name: webs_readTripleFile
Eternal ID of this version: #1011762/12
Text MD5: 4df5b87c1e5b277ea2006a1901d4aaf1
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-03 16:59:45
Source code size: 1227 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 538 / 586
Version history: 11 change(s)
Referenced in: [show references]