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

14
LINES

< > BotCompany Repo | #1013218 // readGlossaryFromWikipedia

JavaX fragment (include)

static Map<S, L<S>> readGlossaryFromWikipedia(S url) {
  new LinkedHashMap<S, L<S>> map;
  S page = loadPage(url + "?action=raw");
  for (S line : lines(page)) {
    L<S> l = regexpFirstGroups(regexpQuote("*'''[[") + "(.+?)" + regexpQuote("]]'''") + "(.*)", line);
    if (nempty(l)) {
      S term = dropStuffBeforeVerticalBar(first(l)), def = second(l);
      L<S> defs = nempties(splitAt(def, "{{snd}}"));
      //print("Term found: " + quote(term) + " - " + sfu(defs));
      map.put(term, defs);
    }
  }
  ret map;
}

Author comment

Began life as a copy of #1013203

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: #1013218
Snippet name: readGlossaryFromWikipedia
Eternal ID of this version: #1013218/3
Text MD5: 7ed46fff73635bebe620f1988fffcb24
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-28 22:14:58
Source code size: 536 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 323 / 344
Version history: 2 change(s)
Referenced in: [show references]