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

14
LINES

< > BotCompany Repo | #1013218 // readGlossaryFromWikipedia

JavaX fragment (include)

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

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: 325 / 346
Version history: 2 change(s)
Referenced in: [show references]