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

91
LINES

< > BotCompany Repo | #1021788 // Gazelle Feedback List Include [Dyn Module]

JavaX fragment (include)

concept AppliedRule {
  S globalID = aGlobalID();
  S ruleID;
  S modifiedRule;
  S outText;
  S judgement;
  S comments;
  S varMap;
  S matchedRuleStruct;
  S intention, context;
}

abstract sclass DynAppliedRules extends DynCRUD<AppliedRule> {
  start {
    dbIndexing(AppliedRule, 'ruleID, AppliedRule, 'context, AppliedRule, 'globalID);
    for (AppliedRule r : list()) fixEntry(r);
    dm_registerAs('gazelleFeedbackCRUD);
    addCountToName();
  }
  
  enhanceFrame { internalFrameIcon(f, gazelle_frameIcon()); }
  
  void fixEntry(AppliedRule r) {
    if (r.ruleID == null) {
      S ruleID = "?";
      pcall {
        ruleID = gazelle_ruleIDFromMatchedRuleStruct(r.matchedRuleStruct);
      }
      cset(r, +ruleID);
    }
    
    if (r.varMap == null) {
      S varMap = "";
      pcall {
        varMap = sfu(gazelle_varMapFromMatchedRuleStruct(r.matchedRuleStruct);
      }
      cset(r, +varMap);
    }
    
    if (r.outText == null) {
      S outText = "";
      pcall {
        outText = gazelle_outTextFromMatchedRuleStruct(r.matchedRuleStruct);
      }
      cset(r, +outText);
    }
    
    if (r.modifiedRule == null) {
      S modifiedRule = "";
      pcall {
        modifiedRule = gazelle_modifiedRuleFromMatchedRuleStruct(r.matchedRuleStruct);
      }
      cset(r, +modifiedRule);
    }
  }
  
  // API
  
  AppliedRule getFeedback(S globalID) {
    ret conceptWhere AppliedRule(+globalID);
  }
  
  L<AppliedRule> feedbackForRule(S ruleID) {
    ret asList(conceptsWhere AppliedRule(+ruleID));
  }
  
  Map<S, Int> stats() {
    ret multiSetToMap(collectMultiSet ruleID(concepts()));
  }
  
  Map<S, Int> statsByJudgement() {
    new MultiSet<S> ms;
    for (AppliedRule r : concepts())
      ms.add(r.ruleID + "/" + r.judgement);
    ret multiSetToMap(ms);
  }
  
  AppliedRule uniqConcept(O... params) {
    AppliedRule r = super.uniqConcept(params);
    fixEntry(r);
    ret r;
  }
  
  Cl<AppliedRule> applicationsForContext(S context) {
    ret conceptsWhere(AppliedRule, +context);
  }
  
  Cl<AppliedRule> allGoodFeedback() {
    ret conceptsWhere(AppliedRule, judgement := 'good);
  }
}

Author comment

Began life as a copy of #1021413

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1021788
Snippet name: Gazelle Feedback List Include [Dyn Module]
Eternal ID of this version: #1021788/10
Text MD5: 27c27d291ebd09cb93c049394b90b132
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-12-19 11:36:05
Source code size: 2213 bytes / 91 lines
Pitched / IR pitched: No / No
Views / Downloads: 213 / 530
Version history: 9 change(s)
Referenced in: [show references]