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

63
LINES

< > BotCompany Repo | #1023524 // Watch this trick [logic engine example, dev.]

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

Uses 911K of libraries. Click here for Pure Java version (7994L/42K).

!7

cmodule WatchThisTrickMate > DynPrintLog {
  class FactCondition implements Runnable {
    S text;
    Runnable action;
    
    *() {}
    *(S *text, Runnable *action) {}
    
    run {
    }
    
    toString { ret "if {" + text + "} => " + action; }
  }

  start-thread {
    dm_useLocalMechListCopies();
    
    /*L<WordTokRule> rules = map wordTokReplacerRuleOnXY(splitAtEmptyLines([[
      [heard] you must watch {this trick}
      => [implied] {this trick} is very good
      
      [heard] you must watch {this trick}
      + [fact] i have watched {this trick}
      => [say] Thanks, I've seen it already
      
      [heard] you must watch {this trick}
      + [fact] i have not watched {this trick}
      => [say] Well... I haven't seen it yet, so maybe I should
    ]]));*/
    
    new L<Runnable> continuations;
    
    L<WordTokRule> rules = ll(
      WordTokReplacer_es1(
        "[heard] you must watch {this trick}", "",
        "[implied] {this trick} is very good"),
        
      WordTokReplacer_es1(
        "[heard] you must watch {this trick}", "",
        "[say] Thanks, I've seen it already") {
        run {
          continuations.add(print(new FactCondition("i have watched {this trick}", r emitOut)));
        }
      }
    );
    
    S s = "you must watch this trick";
    
    pnl(extsToString /*uniquifyMap tok_dropCurlyBrackets*/(iterateHull(func(ExtS s) -> L<ExtS> {
      print("Processing: " + extToString(s));
      ret listPlusNempties_es(
        applyAttractors_es(rules, ll(s)),
        extMap_verbose tok_dropCurlyBrackets(s),
        extMap_verbose ai_dropFillers1(s),
        extMap_verbose ai_groupTheAdjectiveNoun(s),
        extMap_verbose ai_groupSimplestNounPhrases2(s));
    }, makeExt(s, type := "heard"))));
    
    print("Have " + n2(continuations, "continuation"));
  }
}

Author comment

Began life as a copy of #1023502

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

-
Snippet ID: #1023524
Snippet name: Watch this trick [logic engine example, dev.]
Eternal ID of this version: #1023524/31
Text MD5: cfca2b6a0aa0fb1f008a2957d9e1b1f2
Transpilation MD5: 9702f8e58d4ab8430860bda4a31104f3
Author: stefan
Category: javax / logic engines
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-06-28 13:06:59
Source code size: 1896 bytes / 63 lines
Pitched / IR pitched: No / No
Views / Downloads: 378 / 1091
Version history: 30 change(s)
Referenced in: