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)

1  
svoid gazelle_fakery_processInput_multi_v3(TreeMap<S> sections, O... _) {
2  
  int maxMonologue = optPar maxMonologue(_, 0);
3  
  ErrorCounter errorCounter = optPar errorCounter(_, new ErrorCounter);
4  
  for (fS key : startingWithIC(keys(sections), "test input")) errorCounter.run(key, r {
5  
    LS inputLines = tlft(sections.get(key));
6  
    S expectedOutput = sections.get(replaceIC(key, "test input", "expected output"));
7  
    S expectedTempFacts = sections.get(replaceIC(key, "test input", "expected temporary facts"));
8  
    S _preContext = sections.get(replaceIC(key, "test input", "pre-context"));
9  
    print("\nPROCESSING: " + key + "\n");
10  
    temporaryFacts.clear();
11  
    
12  
    LS preContext = tlft(_preContext);
13  
    new LS lines;
14  
    int nMonologue = 0;
15  
    for i over inputLines: {
16  
      S input = inputLines.get(i);
17  
      S user = leadingSquareBracketStuff(input);
18  
      input = dropActuallyLeadingSquareBracketStuff(input);
19  
      gazelle_gatherFulfillments(ll(nu GazelleLine(text := input, extras := litmap(+user))), fulfillments, debug := true);
20  
      preContext.add(input);
21  
      
22  
      O[] subParams = paramsPlus(_,
23  
        userName := user,
24  
        preContext := dropLast(preContext),
25  
        respondingToHuman := nMonologue == 0,
26  
        contextMaker := f<GazelleEvalContext> dm_gazelle_stdEvalContext,
27  
        requiredComment := null, debug := true);
28  
      
29  
      print("useRepeat_v2: " + boolPar useRepeat_v2(_) + ", params: " + _);
30  
      L<GazelleTree> l = boolPar useRepeat_v2(_)
31  
        ? gazelle_reason_repeat_v2(input, subParams)
32  
        : boolPar useRepeat(_, true)
33  
          ? gazelle_reason_repeat(input, subParams)
34  
          : gazelle_reasonWithPreAndPost(input, subParams);
35  
        
36  
      print("Got " + n2(l, "child", "children") + " with line types: " + collect lineType(l));
37  
      for (GazelleTree t : l) {
38  
        if (eq(t.lineType, "temporary fact"))
39  
          temporaryFacts.add(printWithIndent("TEMP FACT> ", t.line));
40  
        else {
41  
          lines.add(printWithIndent("OUT> ", t.line));
42  
          if (++nMonologue < maxMonologue) {
43  
            inputLines.add(t.line);
44  
            preContext.add(t.line);
45  
          }
46  
        }
47  
      }
48  
    }
49  
  
50  
    assertEqualsVerbose(lines, tlft(expectedOutput));
51  
    assertEqualsVerbose(asList(temporaryFacts), tlft(expectedTempFacts));
52  
  });
53  
  errorCounter.print();
54  
}

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: 239 / 267
Version history: 8 change(s)
Referenced in: [show references]