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

41
LINES

< > BotCompany Repo | #1022190 // gazelle_preprocess

JavaX fragment (include)

static Collection<GInterpretable> gazelle_preprocess(S input1, O... _) {
  new L<GInterpretable> interpretables;
  int max = optPar max(_, 20);
  Collector<GInterpretable> collector = limitedCollector(interpretables, max);
  
  new Map<S> evalCache;
  F1<S> eval = boolPar noEvals(_) ? f_id()
    : func(S s) -> S { gazelle_processSafeEvals(s, evalCache) };

  input1 = callF(eval, input1);
  Set<S> texts = litCISet(input1);
  collector.add(GInterpretable(input1));
  RuleEngine2 engine = ((F0<GazelleEvalContext>) optPar contextMaker(_)).get().engine;
  

  int nInterpreted = 0;
  
  bigLoop: while (!collector.full() && nInterpreted < l(interpretables)) {
    GInterpretable workingOn = get(interpretables, nInterpreted);
    S input = workingOn.text;
    S ruleBase = empty(workingOn.ruleID) ? "" : workingOn.ruleID + "+";
    ++nInterpreted;
    
    for (RuleEngine2.SimplifyWithRule rule : engine.splitterRules()) pcall {
      for (S out : gazelle_executeSplitterRule(engine, rule, input))
        if (texts.add(out = callF(eval, out)))
          if (collector.add(new GInterpretable(out, ruleBase + rule.globalID))) break bigLoop;
    }
    
    for (GazelleTree t : dm_gazelle_reasonAboutChatInput_v2(null, input, 
      paramsPlus(_, skipSplitters := true, acceptablePurposes := litset('preprocess), skipUserName := true, skipUserID := true))) {
        S s = callF(eval, t.line);
        if (texts.add(s))
          if (collector.add(new GInterpretable(
            s, ruleBase + t.ruleID(), t.mr)))
              break bigLoop;
    }
  }
      
  ret interpretables;
}

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: 233 / 298
Version history: 10 change(s)
Referenced in: [show references]