1 | sclass Splitter1<A> { |
2 | new MultiSet<A> aExamples; |
3 | new MultiSet<A> bExamples; |
4 | |
5 | // 1 for A, 2 for B, 0 for unknown |
6 | int get(A a) { |
7 | int i = aExamples.get(a)-bExamples.get(a); |
8 | ret i > 0 ? 1 : i < 0 ? 2 : 0; |
9 | } |
10 | |
11 | void learn(A a, bool isB) { |
12 | (isB ? bExamples : aExamples).add(a); |
13 | } |
14 | |
15 | void clear { aExamples.clear(); bExamples.clear(); } |
16 | } |
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: | 568 / 1123 |
Version history: | 2 change(s) |
Referenced in: | [show references] |