sclass Splitter1<A> { new MultiSet<A> aExamples; new MultiSet<A> bExamples; // 1 for A, 2 for B, 0 for unknown int get(A a) { int i = aExamples.get(a)-bExamples.get(a); ret i > 0 ? 1 : i < 0 ? 2 : 0; } void learn(A a, bool isB) { (isB ? bExamples : aExamples).add(a); } void clear { aExamples.clear(); bExamples.clear(); } }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1009690 |
Snippet name: | Splitter1 - sorts things in 2 categories, collects examples with occurrence count |
Eternal ID of this version: | #1009690/3 |
Text MD5: | 62cb228856a6d7ab535ccbdea0c59fb7 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-08-14 02:33:45 |
Source code size: | 376 bytes / 16 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 567 / 1122 |
Version history: | 2 change(s) |
Referenced in: | [show references] |