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

19
LINES

< > BotCompany Repo | #1000493 // LRemoveInputSuffix (learner)

JavaX fragment (include)

// learns to remove input suffixes.

static class LRemoveInputSuffix extends LearnerImpl {
  static boolean debug;
  String suffix;
  static boolean failFast = false;
  
  public void processInOut(Object _in, Object _out) {
    String in = (String) _in, out = (String) _out;
    if (!in.startsWith(out)) fail();
    suffix = overwrite(suffix, in.substring(out.length()));
  }

  public String processIn(Object _in) {
    String in = (String) _in;
    if (!in.endsWith(suffix)) if (failFast) fail(); else return in;
    return in.substring(0, in.length()-suffix.length());
  }
}

Author comment

Began life as a copy of #1000492

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1000493
Snippet name: LRemoveInputSuffix (learner)
Eternal ID of this version: #1000493/1
Text MD5: 2b7066396a4606cd08be77bad3b34162
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-09 16:28:13
Source code size: 597 bytes / 19 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 579 / 1508
Referenced in: [show references]