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

26
LINES

< > BotCompany Repo | #1008052 // levenClosestIC - get Levenshtein-closest key in map or element in list (ignoring case)

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2480L/16K).

static <A> S levenClosestIC(Map<S, A> map, S s) {
  ret levenClosestIC(keys(map), s);
}

sS levenClosestIC(Collection<S> l, S s) {
  ret levenClosestIC(l, s, Int.MAX_VALUE-2);
}

sS levenClosestIC(Collection<S> l, S s, int limit) {
  ++limit;
  new Lowest<S> best;
  for (S key : unnull(l)) {
    limit = leven_limitedIC(s, key, limit);
    best.put(key, limit);
    if (limit == 0) break;
  }
  ret best!;
}

static <A> S levenClosestIC(S s, Map<S, A> map) {
  ret levenClosestIC(map, s);
}

sS levenClosestIC(S s, Collection<S> l) {
  ret levenClosestIC(l, s);
}

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: #1008052
Snippet name: levenClosestIC - get Levenshtein-closest key in map or element in list (ignoring case)
Eternal ID of this version: #1008052/11
Text MD5: 84b1fbf6713bb85068c1854ae676bb02
Transpilation MD5: 65581e7075a54c9143c44f5cfe4a57d5
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-28 12:26:38
Source code size: 589 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 590 / 696
Version history: 10 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1008384 - levenClosest - get Levenshtein-closest key in map (case-sensitive)
#1025879 - levenWithSwapsClosestIC [dev., needs levenWithSwaps_limitedIC] - get Levenshtein-with-swaps-closest key in map or element in list (ignoring case)