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

41
LINES

< > BotCompany Repo | #1022190 // gazelle_preprocess

JavaX fragment (include)

1  
static Collection<GInterpretable> gazelle_preprocess(S input1, O... _) {
2  
  new L<GInterpretable> interpretables;
3  
  int max = optPar max(_, 20);
4  
  Collector<GInterpretable> collector = limitedCollector(interpretables, max);
5  
  
6  
  new Map<S> evalCache;
7  
  F1<S> eval = boolPar noEvals(_) ? f_id()
8  
    : func(S s) -> S { gazelle_processSafeEvals(s, evalCache) };
9  
10  
  input1 = callF(eval, input1);
11  
  Set<S> texts = litCISet(input1);
12  
  collector.add(GInterpretable(input1));
13  
  RuleEngine2 engine = ((F0<GazelleEvalContext>) optPar contextMaker(_)).get().engine;
14  
  
15  
16  
  int nInterpreted = 0;
17  
  
18  
  bigLoop: while (!collector.full() && nInterpreted < l(interpretables)) {
19  
    GInterpretable workingOn = get(interpretables, nInterpreted);
20  
    S input = workingOn.text;
21  
    S ruleBase = empty(workingOn.ruleID) ? "" : workingOn.ruleID + "+";
22  
    ++nInterpreted;
23  
    
24  
    for (RuleEngine2.SimplifyWithRule rule : engine.splitterRules()) pcall {
25  
      for (S out : gazelle_executeSplitterRule(engine, rule, input))
26  
        if (texts.add(out = callF(eval, out)))
27  
          if (collector.add(new GInterpretable(out, ruleBase + rule.globalID))) break bigLoop;
28  
    }
29  
    
30  
    for (GazelleTree t : dm_gazelle_reasonAboutChatInput_v2(null, input, 
31  
      paramsPlus(_, skipSplitters := true, acceptablePurposes := litset('preprocess), skipUserName := true, skipUserID := true))) {
32  
        S s = callF(eval, t.line);
33  
        if (texts.add(s))
34  
          if (collector.add(new GInterpretable(
35  
            s, ruleBase + t.ruleID(), t.mr)))
36  
              break bigLoop;
37  
    }
38  
  }
39  
      
40  
  ret interpretables;
41  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1022190
Snippet name: gazelle_preprocess
Eternal ID of this version: #1022190/11
Text MD5: ff1743dcac64394a05e9f8cdf6b7273a
Author: stefan
Category: javax / gazelle
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-21 01:05:55
Source code size: 1622 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 344 / 409
Version history: 10 change(s)
Referenced in: [show references]