1 | sclass AI_SubSpace implements AI_PostHandler, AI_CacheChecker { |
2 | int limit; |
3 | new MultiMap<Symbol, WebNode> index; |
4 | new HashMap<GlobalID, Web> websByID; |
5 | new L<Web> webs; |
6 | bool changed; |
7 | |
8 | *() {} |
9 | *(int *limit) {} |
10 | |
11 | // existence of triple has already been checked |
12 | public GlobalID postTriple(T3<Symbol> t) { |
13 | if (limitReached()) fail("Subspace limit reached"); |
14 | Web web = webFromTriple(t); |
15 | web.source = ai_currentMaker(); |
16 | addWeb(web); |
17 | ret web.globalIDObj(); |
18 | } |
19 | |
20 | public GlobalID postTriple(T3<Symbol> t, bool verified) { |
21 | ret postTriple(t); // XXX |
22 | } |
23 | |
24 | void addWeb(Web web) { |
25 | websByID.put(web.globalIDObj(), web); |
26 | webs.add(web); |
27 | changed = true; |
28 | for (WebNode node : web_nodesAndRelations(web)) |
29 | for (S text : asSet(node.texts())) |
30 | index.put(symbol(ai_shortenForIndex(text)), node); |
31 | } |
32 | |
33 | public bool hasTriple(Symbol a, Symbol b, Symbol c) { |
34 | L<Web> webs = ai_withoutInvalidWebs(nodesToWebs(shortestList3( |
35 | index.get(a), |
36 | index.get(b), |
37 | index.get(c)))); |
38 | ret webs_search_noVar_bool(webFromTriple(a, b, c), webs); |
39 | } |
40 | |
41 | bool limitReached() { |
42 | ret limit > 0 && l(websByID) >= limit; |
43 | } |
44 | |
45 | L<WebNode> indexedNodes_rawLookup(Symbol s) { |
46 | ret index.get(ai_shortenForIndex(s)); |
47 | } |
48 | |
49 | int numWebs() { ret l(websByID); } |
50 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1012051 |
Snippet name: | AI_SubSpace (phased out in favor of ActualThoughtSpace) |
Eternal ID of this version: | #1012051/23 |
Text MD5: | 3fcaf307c0e4efd6d4756a2eb60e8aec |
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-16 13:58:33 |
Source code size: | 1370 bytes / 50 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 536 / 1157 |
Version history: | 22 change(s) |
Referenced in: | [show references] |