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

40
LINES

< > BotCompany Repo | #1022407 // dm_gazelle_matchStep_condition

JavaX fragment (include)

svoid dm_gazelle_matchStep_condition(GazelleTree t, O... _) {
  if (t.rule() == null) ret;
  bool debug = boolPar debug(_) || boolPar debugConditions(_);
  GRuleLine next = get(t.rule().insWithType, t.mr.iCond);
  if (debug) print("matchStep_condition: " + getString type(next));
  if (next == null || !eq(next.type, "condition")) ret;
  
  bool satisfied = false;
  
  //S cond = next.text;
  S cond = t.mr.applyMappingTo(next);
  
  if (gazelle_isEmbeddedEval(cond)) {
    if (debug) print("Embedded eval: " + cond);
    satisfied = eqic(dm_processEmbeddedSafeEvals(cond), "true");
  } else {
    GazelleEvalContext subCtx = cast callF(requiredPar contextMaker(_));
    subCtx.engine.dropRulesWhere(r -> neq(r.purpose, "condition to eval"));
    L<GazelleTree> l = dm_gazelle_reasonAboutChatInput_v2(null, cond, paramsPlus(paramsMinus(_, 'acceptablePurposes), ctx := subCtx));
    gazelle_processSafeEvalsInTree(l);
    if (debug) {
      print("Sub-Tree for condition " + cond + ":");
      printIndentLines(l);
    }
  
    for (GazelleTree tree : l)
      if (eqic(tree.line, "true"))
        break with satisfied = true;
      else if (eqic(tree.line, "false"))
        break;
  }
      
  if (debug) print("satisfied=" + satisfied);
  if (!satisfied) ret;
  
  t.mr.iCond++;
  gazelle_addPredictionToTreeNode(t);
  t.mr.remainingConditions = dropFirst(t.mr.remainingConditions);
  t.mr.remainingConditionsWithType = dropFirst(t.mr.remainingConditionsWithType);
}

Author comment

Began life as a copy of #1022400

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: #1022407
Snippet name: dm_gazelle_matchStep_condition
Eternal ID of this version: #1022407/14
Text MD5: fded3dc288f675e3052db4faa38daf37
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-17 16:42:26
Source code size: 1508 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 253 / 285
Version history: 13 change(s)
Referenced in: [show references]