Libraryless. Click here for Pure Java version (7163L/48K).
1 | // for ai_language() |
2 | // Uses mech list "All $language word categories" and sublists |
3 | scope ai_wordToCategories. |
4 | |
5 | static TimedCache<Map<S, Map<S, Set<S>>>> #cache = new TimedCache(f ciMap, 10.0); // language -> word -> categories |
6 | |
7 | static Map<S, Set<S>> ai_wordToCategories() { |
8 | Map<S, Map<S, Set<S>>> languages = cache!; |
9 | Map<S, Set<S>> map = languages.get(ai_language()); |
10 | if (map == null) |
11 | languages.put(ai_language(), map = make()); |
12 | ret map; |
13 | } |
14 | |
15 | static Map<S, Set<S>> #make() { |
16 | Map<S, Set<S>> catMap = ai_wordCategoriesWithElements(); |
17 | |
18 | final Map<S, Set<S>> map = ciMap(); |
19 | for (S cat : keys(catMap)) |
20 | for (S word : catMap.get(cat)) { |
21 | Set<S> set = map.get(word); |
22 | if (set == null) map.put(word, set = new LinkedHashSet); |
23 | set.add(cat); |
24 | } |
25 | ret map; |
26 | } |
27 | |
28 | static Set<S> ai_wordToCategories(S word) { |
29 | ret ai_wordToCategories().get(word); |
30 | } |
31 | |
32 | end scope |
Began life as a copy of #1017360
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1017446 |
Snippet name: | ai_wordToCategories |
Eternal ID of this version: | #1017446/6 |
Text MD5: | 365aee1c266fc748894a6bf8fdab8573 |
Transpilation MD5: | 0d6d83a76df44697a23db269d7b70310 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-04-16 13:38:40 |
Source code size: | 915 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 414 / 552 |
Version history: | 5 change(s) |
Referenced in: | [show references] |