Download Jar. Libraryless. Click here for Pure Java version (3630L/23K).
!7 static SS map = unstructMap([[lhm{null="assumed", "what is a bear?"="rejected", "a bear is an animal"="assumed", "a bear is dangerous"="assumed", "\"dude\" is a word for someone"="assumed", "Pouet is a website"="assumed", "an integer is a whole number"="assumed", "what is a small bird"="rejected", "what is a good joke"="assumed", "peter is a fun guy"="confirmed", "john is a person"="confirmed"}]]); static L<S> tests = ll("what is a bunny", "klaus is a fool", "john is a joker"); p { dropValuesFromMapOtherThan(map, 'confirmed, 'rejected); final int wordIndex = 0; L<S> input = map(func(S s) { getWord(s, wordIndex) }, keys(map)); L<S> output = valuesList(map); Map<S, Bool> map = mapValuesToBool(twoListsToHashMap(input, output), 'confirmed); int diff = countValues(map, true)-countValues(map, false); print("diff=" + diff); final bool defaultValue = diff > 0; final Set<S> exceptions = new TreeSet(keysWithValue(map, !defaultValue)); O decider = func(S s) { contains(exceptions, getWord(s, wordIndex)) ? !defaultValue : defaultValue }; for (S test : tests) print(" " + test + " => " + callF(decider, test)); }
Began life as a copy of #1010868
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: | #1010883 |
Snippet name: | Decide by word at index v2 [OK] |
Eternal ID of this version: | #1010883/11 |
Text MD5: | 867d193641a2c75369c5b79780a15a64 |
Transpilation MD5: | fe0c3a7d566f1f7b56dcd5f0cc8111f1 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-10-05 14:55:16 |
Source code size: | 1173 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 608 / 1248 |
Version history: | 10 change(s) |
Referenced in: | [show references] |