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

46
LINES

< > BotCompany Repo | #1017701 // Telegram Facts Bot v3 [Dyn Module, with underscore dollar vars, OK]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 408K of libraries. Compilation Failed (22173L/165K).

!7

set flag DynModule.

sclass TelegramFactsBot > AbstractTelegramThinkBot {
  S evalExp(Exp e) {
    S code = nlLogic_text(e);
    print("Eval'ing: " + code);
    temp tempAdd(hotwire_copyOver_after, voidfunc(Class c) {
      copyFields(mc(), c, 'telegram_msg_tl)
    });
    S result = str(javaEval(code));
    print("Result: " + shorten(result, 100));
    ret result;
  }

  void thinkAbout(S s) {
    NLLogicChecker_v2 c = new NLLogicChecker_v2 {
      bool checkExpression(Exp e, Matching m) {
        if (e cast Func) {
          if (eq(e.name, "verbPhraseFromThirdPerson"))
            ret nlLogic_stringFunction(f ai_verbPhraseFromThirdPerson, e, m.matches);
          else if (eq(e.name, "singular"))
            ret nlLogic_stringFunction(f singular, e, m.matches);
          else if (eq(e.name, 'eval))
            ret eq("true", evalExp(e.arg));
        }
        
        if (e cast Eq) {
          Exp r = e.right;
          S var = nlLogic_text(e.left);
          if (r cast Func) pcall {
            if (eq(r.name, 'eval))
              ret new NLStringMatcher_singleDollarVar().match(var, evalExp(r.arg), m.matches);
          }
        }
        
        ret super.checkExpression(e, m);
      }
    };
    c.matcher = new NLStringMatcher_dollarVars_underscores;
    c.input = s;
    c.facts = mL_facts();
    applyNLLogicFacts_v2(c, voidfunc(S s) { postMessage(s) }, ai_mL_parsedLogicExamples());
  }
}

Author comment

Began life as a copy of #1017593

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1017701
Snippet name: Telegram Facts Bot v3 [Dyn Module, with underscore dollar vars, OK]
Eternal ID of this version: #1017701/19
Text MD5: e43eb4948ad4261cce77b4fbff4e1ce3
Transpilation MD5: ca94e82dc0773fbc96fb892fa67b3688
Author: stefan
Category: javax / telegram
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-07 21:27:44
Source code size: 1467 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 323 / 2640
Version history: 18 change(s)
Referenced in: [show references]