Libraryless. Click here for Pure Java version (7408L/50K/163K).
1 | !7 |
2 | |
3 | p {
|
4 | Concepts concepts = new Concepts(#1008059).safeLoad(); |
5 | Concept bot = findConceptWhere(concepts, "SelectBot", name := "greet"); |
6 | Map<S, Bool> examples = (Map) get(bot, "examples"); |
7 | testGuessMethod(examples, filterByValue(examples, true), f guess_match); |
8 | } |
9 | |
10 | static bool guess_match(Map<S, Bool> examples, S s) {
|
11 | for (S key : keys(examples)) |
12 | if (match(key, s)) |
13 | ret examples.get(key); |
14 | false; |
15 | } |
16 | |
17 | static void testGuessMethod(Map<S, Bool> examples, Map<S, Bool> filteredExamples, O method) {
|
18 | new Scorer scorer; |
19 | for (S key : keys(examples)) {
|
20 | Bool value = examples.get(key); |
21 | if (value == null) continue; |
22 | bool guessed = isTrue(callF(method, filteredExamples, key)); |
23 | scorer.add(eq(value, guessed)); |
24 | } |
25 | scorer.print(); |
26 | } |
27 | |
28 | sclass Scorer {
|
29 | int score, total; |
30 | |
31 | void add(bool correct) {
|
32 | ++total; |
33 | if (correct) ++score; |
34 | } |
35 | |
36 | void print() {
|
37 | main.print(ratioToIntPercent(score, total) + "% correct"); |
38 | } |
39 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1008063 |
| Snippet name: | Test guess methods [dev.] |
| Eternal ID of this version: | #1008063/7 |
| Text MD5: | d95a661f82bff98cb832080ff1cde67a |
| Transpilation MD5: | 1fd894e7cb1bd2bf6c38f04a8a5e9178 |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-04-23 13:50:32 |
| Source code size: | 998 bytes / 39 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 701 / 812 |
| Version history: | 6 change(s) |
| Referenced in: | [show references] |