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

39
LINES

< > BotCompany Repo | #1005428 // solvableSmartQuestions2 - get solvable questions (and answers) from Smart Console as MultiMap

JavaX fragment (include)

1  
sbool solvableSmartQuestions2_debug;
2  
3  
static MultiMap<S, S> solvableSmartQuestions2() {
4  
  Map<Long, O> concepts = safeLoadConcepts("#1005320");
5  
  new MultiMap<S, S> map;
6  
  L uls = valuesOfType(concepts, "main$UserLine");
7  
  if (solvableSmartQuestions2_debug) print("uls: " + l(uls));
8  
  for (O ul : uls) {
9  
    L backRefs = cast getOptDyn(ul, "backRefs");
10  
    if (backRefs == null) {
11  
      if (solvableSmartQuestions2_debug) print("No backrefs");
12  
      continue;
13  
    }
14  
    if (solvableSmartQuestions2_debug) print("backrefs: " + l(backRefs));
15  
    S q = getString(ul, "text");
16  
    for (O ref : backRefs) {
17  
      O ua = getOptDyn(ref, "this$1");
18  
      if (ua == null) {
19  
        if (solvableSmartQuestions2_debug) print("No backref value");
20  
        continue;
21  
      }
22  
      S cn = shortDynamicClassName(ua);
23  
      if (neq(cn, "UserAnswer")) {
24  
        O id = getOptDyn(ua, "id");
25  
        if (solvableSmartQuestions2_debug)
26  
          print("id: " + id + ", classname: " + cn + ", " + getClassName(ua) + ", " + struct(allFields(ua)));
27  
        continue;
28  
      }
29  
      bool solvable = getBool(ua, "solvable");
30  
      S a = getString(ua, "text");
31  
      if (!solvable) {
32  
        if (solvableSmartQuestions2_debug) print("Not solvable: " + a);
33  
        continue;
34  
      }
35  
      map.put(q, a);
36  
    }
37  
  }
38  
  ret map;
39  
}

Author comment

Began life as a copy of #1005406

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005428
Snippet name: solvableSmartQuestions2 - get solvable questions (and answers) from Smart Console as MultiMap
Eternal ID of this version: #1005428/1
Text MD5: 83ae2639797b4337b55790e47170a49c
Author: stefan
Category: javax / concepts
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-11-16 17:32:28
Source code size: 1335 bytes / 39 lines
Pitched / IR pitched: No / No
Views / Downloads: 465 / 476
Referenced in: [show references]