Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

39
LINES

< > BotCompany Repo | #1008063 // Test guess methods [dev.]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (7408L/50K/163K).

!7

p {
  Concepts concepts = new Concepts(#1008059).safeLoad();
  Concept bot = findConceptWhere(concepts, "SelectBot", name := "greet");
  Map<S, Bool> examples = (Map) get(bot, "examples");
  testGuessMethod(examples, filterByValue(examples, true), f guess_match);
}

static bool guess_match(Map<S, Bool> examples, S s) {
  for (S key : keys(examples))
    if (match(key, s))
      ret examples.get(key);
  false;
}

static void testGuessMethod(Map<S, Bool> examples, Map<S, Bool> filteredExamples, O method) {
  new Scorer scorer;
  for (S key : keys(examples)) {
    Bool value = examples.get(key);
    if (value == null) continue;
    bool guessed = isTrue(callF(method, filteredExamples, key));
    scorer.add(eq(value, guessed));
  }
  scorer.print();
}

sclass Scorer {
  int score, total;
  
  void add(bool correct) {
    ++total;
    if (correct) ++score;
  }
  
  void print() {
    main.print(ratioToIntPercent(score, total) + "% correct");
  }
}

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: 386 / 432
Version history: 6 change(s)
Referenced in: [show references]