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

54
LINES

< > BotCompany Repo | #1022480 // gazelle_fakery_processInput_multi_v3 (with pre+post)

JavaX fragment (include)

svoid gazelle_fakery_processInput_multi_v3(TreeMap<S> sections, O... _) {
  int maxMonologue = optPar maxMonologue(_, 0);
  ErrorCounter errorCounter = optPar errorCounter(_, new ErrorCounter);
  for (fS key : startingWithIC(keys(sections), "test input")) errorCounter.run(key, r {
    LS inputLines = tlft(sections.get(key));
    S expectedOutput = sections.get(replaceIC(key, "test input", "expected output"));
    S expectedTempFacts = sections.get(replaceIC(key, "test input", "expected temporary facts"));
    S _preContext = sections.get(replaceIC(key, "test input", "pre-context"));
    print("\nPROCESSING: " + key + "\n");
    temporaryFacts.clear();
    
    LS preContext = tlft(_preContext);
    new LS lines;
    int nMonologue = 0;
    for i over inputLines: {
      S input = inputLines.get(i);
      S user = leadingSquareBracketStuff(input);
      input = dropActuallyLeadingSquareBracketStuff(input);
      gazelle_gatherFulfillments(ll(nu GazelleLine(text := input, extras := litmap(+user))), fulfillments, debug := true);
      preContext.add(input);
      
      O[] subParams = paramsPlus(_,
        userName := user,
        preContext := dropLast(preContext),
        respondingToHuman := nMonologue == 0,
        contextMaker := f<GazelleEvalContext> dm_gazelle_stdEvalContext,
        requiredComment := null, debug := true);
      
      print("useRepeat_v2: " + boolPar useRepeat_v2(_) + ", params: " + _);
      L<GazelleTree> l = boolPar useRepeat_v2(_)
        ? gazelle_reason_repeat_v2(input, subParams)
        : boolPar useRepeat(_, true)
          ? gazelle_reason_repeat(input, subParams)
          : gazelle_reasonWithPreAndPost(input, subParams);
        
      print("Got " + n2(l, "child", "children") + " with line types: " + collect lineType(l));
      for (GazelleTree t : l) {
        if (eq(t.lineType, "temporary fact"))
          temporaryFacts.add(printWithIndent("TEMP FACT> ", t.line));
        else {
          lines.add(printWithIndent("OUT> ", t.line));
          if (++nMonologue < maxMonologue) {
            inputLines.add(t.line);
            preContext.add(t.line);
          }
        }
      }
    }
  
    assertEqualsVerbose(lines, tlft(expectedOutput));
    assertEqualsVerbose(asList(temporaryFacts), tlft(expectedTempFacts));
  });
  errorCounter.print();
}

Author comment

Began life as a copy of #1022242

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1022480
Snippet name: gazelle_fakery_processInput_multi_v3 (with pre+post)
Eternal ID of this version: #1022480/9
Text MD5: 101d84cf1384c5f93ffb9e5086d5520b
Author: stefan
Category: javax / gazelle
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-22 17:01:06
Source code size: 2376 bytes / 54 lines
Pitched / IR pitched: No / No
Views / Downloads: 318 / 345
Version history: 8 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)