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).

1  
!7
2  
3  
set flag DynModule.
4  
5  
sclass TelegramFactsBot > AbstractTelegramThinkBot {
6  
  S evalExp(Exp e) {
7  
    S code = nlLogic_text(e);
8  
    print("Eval'ing: " + code);
9  
    temp tempAdd(hotwire_copyOver_after, voidfunc(Class c) {
10  
      copyFields(mc(), c, 'telegram_msg_tl)
11  
    });
12  
    S result = str(javaEval(code));
13  
    print("Result: " + shorten(result, 100));
14  
    ret result;
15  
  }
16  
17  
  void thinkAbout(S s) {
18  
    NLLogicChecker_v2 c = new NLLogicChecker_v2 {
19  
      bool checkExpression(Exp e, Matching m) {
20  
        if (e cast Func) {
21  
          if (eq(e.name, "verbPhraseFromThirdPerson"))
22  
            ret nlLogic_stringFunction(f ai_verbPhraseFromThirdPerson, e, m.matches);
23  
          else if (eq(e.name, "singular"))
24  
            ret nlLogic_stringFunction(f singular, e, m.matches);
25  
          else if (eq(e.name, 'eval))
26  
            ret eq("true", evalExp(e.arg));
27  
        }
28  
        
29  
        if (e cast Eq) {
30  
          Exp r = e.right;
31  
          S var = nlLogic_text(e.left);
32  
          if (r cast Func) pcall {
33  
            if (eq(r.name, 'eval))
34  
              ret new NLStringMatcher_singleDollarVar().match(var, evalExp(r.arg), m.matches);
35  
          }
36  
        }
37  
        
38  
        ret super.checkExpression(e, m);
39  
      }
40  
    };
41  
    c.matcher = new NLStringMatcher_dollarVars_underscores;
42  
    c.input = s;
43  
    c.facts = mL_facts();
44  
    applyNLLogicFacts_v2(c, voidfunc(S s) { postMessage(s) }, ai_mL_parsedLogicExamples());
45  
  }
46  
}

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: 326 / 2646
Version history: 18 change(s)
Referenced in: [show references]