1 | sbool indexedSimpleWikipedia_magicMap_debug; |
2 | |
3 | srecord WikiPage(S title, S text) {} |
4 | |
5 | static Map<S, WikiPage> indexedSimpleWikipedia_magicMap(final Map<S, IndexedWikiPage> map) { |
6 | final File f = unpackSimpleWikipedia(); |
7 | Map<S, WikiPage> actualMap = new TreeMap<S, WikiPage>(caseInsensitiveComparator()) { |
8 | public WikiPage get(O title) { |
9 | IndexedWikiPage ip = map.get(title); |
10 | if (ip == null) null; |
11 | |
12 | S xml = loadTextFilePart(f, ip.start, ip.start+ip.len); |
13 | if (indexedSimpleWikipedia_magicMap_debug) { |
14 | print("Loaded from " + ip.start + " to " + (ip.start+ip.len)); |
15 | printIndent(xml); |
16 | } |
17 | |
18 | L<S> tok = htmlTok(xml); |
19 | S realTitle = trim(htmldecode(join(contentsOfContainerTag(tok, "title")))); |
20 | S text = trim(htmldecode(join(contentsOfContainerTag(tok, "text")))); |
21 | ret WikiPage(realTitle, text); |
22 | } |
23 | }; |
24 | for (S title : keys(map)) |
25 | actualMap.put(title, null); // dummy entry to have key |
26 | ret actualMap; |
27 | } |
Began life as a copy of #1014162
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: | #1014164 |
Snippet name: | indexedSimpleWikipedia_magicMap - produces a "magic" map that loads on demand |
Eternal ID of this version: | #1014164/1 |
Text MD5: | 84b937328cc8658adf16e49e820fb310 |
Author: | stefan |
Category: | javax / a.i. / networking |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-04-15 14:17:00 |
Source code size: | 1012 bytes / 27 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 339 / 365 |
Referenced in: | [show references] |