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

23
LINES

< > BotCompany Repo | #1008054 - SelectBot

JavaX fragment (include)

sclass SelectBot<A> extends Concept {
  new TreeMap<S, A> examples;
  new TreeMap<S, A> guessed;
  transient S lastMatch;
  
  void put(S s, A value) {
    examples.put(s, value);
    guessed.remove(s);
    change();
  }

  A get(S s) {
    lastMatch = guess(s);
    A value = mapGet(examples, lastMatch);
    if (neq(lastMatch, s))
      if (mapPutIfChange(guessed, s, value)) change();
    ret value;
  }
  
  S guess(S s) {
    ret levenClosestIC(examples, s);
  }
}

download  show line numbers  debug dex   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1008054
Snippet name: SelectBot
Eternal ID of this version: #1008054/13
Text MD5: de015b868cf4f0567a658138405e6c33
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-23 13:53:21
Source code size: 491 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 409 / 856
Version history: 12 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1008054 & http://1008054.tinybrain.de