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

32
LINES

< > BotCompany Repo | #1028934 // ai_ruleOfThree_solver_4 - like solver_1 but finds suffixes from repeated word parts (e.g. "fall-ing")

JavaX fragment (include) [tags: use-pretranspiled]

Uses 11335K of libraries. Click here for Pure Java version (11294L/75K).

1  
sS ai_ruleOfThree_solver_4(S db, S input) {
2  
  ret fixAOrAn(getVar(lastThat(ti -> !isTrue(getOptDyn(ti, "splitOffSuffixes")), too_transformInput_returnAll(input, too -> {
3  
    // load rules
4  
    too.addAll(lambdaMap ai_parseBasicLogicRule(tlft(db)));
5  
  
6  
    // find suffixes, transform everything accordingly
7  
    too.addTransformer(func(BasicLogicRule<S> r) {
8  
      Set<S> suffixes = ai_suffixesFromSharedWordStarts(r);
9  
      if (nempty(suffixes)) {
10  
        print(+suffixes);
11  
        // found suffixes. now transform all inputs & rules
12  
        too.addTransformer(func(IInput<S> i) {
13  
          setOptAndReturn(TransformedInput(ai_splitOffWordSuffixes(suffixes, i!)), splitOffSuffixes := true)
14  
        });
15  
        too.addTransformer(func(BasicLogicRule<S> r) {
16  
          mapBasicLogicRule(r, s -> ai_splitOffWordSuffixes(suffixes, s))
17  
        });
18  
        // tack suffixes back on
19  
        too.addTransformer(func(IInput<S> i) {
20  
          TransformedInput(ai_remergeWordSuffixes(suffixes, i!))
21  
        });
22  
      }
23  
      null;
24  
    });
25  
  
26  
    // turn words appearing in LHS and RHS into variables
27  
    too.addTransformer(f<BasicLogicRule<S>, O> ai_sharedPhrasesIntoDollarVars);
28  
    
29  
    // match input with rules
30  
    too_flexMatchRulesToTransformInput(too);
31  
  }))));
32  
}

Author comment

Began life as a copy of #1028917

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1028934
Snippet name: ai_ruleOfThree_solver_4 - like solver_1 but finds suffixes from repeated word parts (e.g. "fall-ing")
Eternal ID of this version: #1028934/14
Text MD5: fe6abdd241c7ea55b5d838ad045bf12f
Transpilation MD5: d0a2ab95838ac5688454a35bf7fa1c44
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-12 13:17:22
Source code size: 1289 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 305 / 412
Version history: 13 change(s)
Referenced in: [show references]