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)

sbool solvableSmartQuestions2_debug;

static MultiMap<S, S> solvableSmartQuestions2() {
  Map<Long, O> concepts = safeLoadConcepts("#1005320");
  new MultiMap<S, S> map;
  L uls = valuesOfType(concepts, "main$UserLine");
  if (solvableSmartQuestions2_debug) print("uls: " + l(uls));
  for (O ul : uls) {
    L backRefs = cast getOptDyn(ul, "backRefs");
    if (backRefs == null) {
      if (solvableSmartQuestions2_debug) print("No backrefs");
      continue;
    }
    if (solvableSmartQuestions2_debug) print("backrefs: " + l(backRefs));
    S q = getString(ul, "text");
    for (O ref : backRefs) {
      O ua = getOptDyn(ref, "this$1");
      if (ua == null) {
        if (solvableSmartQuestions2_debug) print("No backref value");
        continue;
      }
      S cn = shortDynamicClassName(ua);
      if (neq(cn, "UserAnswer")) {
        O id = getOptDyn(ua, "id");
        if (solvableSmartQuestions2_debug)
          print("id: " + id + ", classname: " + cn + ", " + getClassName(ua) + ", " + struct(allFields(ua)));
        continue;
      }
      bool solvable = getBool(ua, "solvable");
      S a = getString(ua, "text");
      if (!solvable) {
        if (solvableSmartQuestions2_debug) print("Not solvable: " + a);
        continue;
      }
      map.put(q, a);
    }
  }
  ret map;
}

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: 459 / 468
Referenced in: [show references]