1 | // learns to remove input suffixes. |
2 | |
3 | static class LRemoveInputSuffix extends LearnerImpl {
|
4 | static boolean debug; |
5 | String suffix; |
6 | static boolean failFast = false; |
7 | |
8 | public void processInOut(Object _in, Object _out) {
|
9 | String in = (String) _in, out = (String) _out; |
10 | if (!in.startsWith(out)) fail(); |
11 | suffix = overwrite(suffix, in.substring(out.length())); |
12 | } |
13 | |
14 | public String processIn(Object _in) {
|
15 | String in = (String) _in; |
16 | if (!in.endsWith(suffix)) if (failFast) fail(); else return in; |
17 | return in.substring(0, in.length()-suffix.length()); |
18 | } |
19 | } |
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: | 904 / 1833 |
| Referenced in: | [show references] |