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

41
LINES

< > BotCompany Repo | #1011762 // webs_readTripleFile

JavaX fragment (include)

static L<Web> webs_readTripleFile(File f) {
  // parallel isn't even faster
  //if (hasMultipleCores()) ret webs_readTripleFile_parallel(f);
  
  if (!f.exists()) ret ll();
  Iterator<S> it = linesFromFile(f);
  //L<S> names = (L) unstructure(it.next());
  new L<S> names;
  while (it.hasNext()) {
    S s = trim(it.next());
    if (empty(s)) break;
    names.add(unquote(s));
  }
  
  new L<Web> webs;
  while (it.hasNext()) {
    S s = it.next();
    pcall {
      addIfNotNull(webs, webs_readTripleFile_line(s, names));
    }
  }
  ret webs;
}

static Web webs_readTripleFile_line(S s, L<S> names) {
  // S moreInfo = quote(unnull(web.globalID)) + " " + quote(unnull(web.title)) + " " + quote(unnull(web.source)) + " " + (web.unverified ? "u" : "v") + " " + web.created;
  L<S> l = javaTokC(s);
  if (l(l) == 8) {
    Web web = webFromTriple(
      names.get(parseInt(first(l))), 
      names.get(parseInt(second(l))),
      names.get(parseInt(third(l))));
    web.globalID = unquote(l.get(3));
    web.title = unquote(l.get(4));
    web.source = unquote(l.get(5));
    web.unverified = !eq(l.get(6), "v");
    web.created = parseLong(l.get(7));
    ret web_intern(web);
  }
  null;
}

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: 537 / 585
Version history: 11 change(s)
Referenced in: [show references]