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).

1  
static <A> S levenClosestIC(Map<S, A> map, S s) {
2  
  ret levenClosestIC(keys(map), s);
3  
}
4  
5  
sS levenClosestIC(Collection<S> l, S s) {
6  
  ret levenClosestIC(l, s, Int.MAX_VALUE-2);
7  
}
8  
9  
sS levenClosestIC(Collection<S> l, S s, int limit) {
10  
  ++limit;
11  
  new Lowest<S> best;
12  
  for (S key : unnull(l)) {
13  
    limit = leven_limitedIC(s, key, limit);
14  
    best.put(key, limit);
15  
    if (limit == 0) break;
16  
  }
17  
  ret best!;
18  
}
19  
20  
static <A> S levenClosestIC(S s, Map<S, A> map) {
21  
  ret levenClosestIC(map, s);
22  
}
23  
24  
sS levenClosestIC(S s, Collection<S> l) {
25  
  ret levenClosestIC(l, s);
26  
}

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: 595 / 702
Version history: 10 change(s)
Referenced in: [show references]