Libraryless. Click here for Pure Java version (3101L/19K).
1 | // patterns = e.g. "Zitat, Anfrage, Preis, Kosten, Preise, Geld, wieviel, wie + viel" |
2 | // potentially slow (not using levenLimited) |
3 | static Int mmo_levenWithSwapsScore(S patterns, S s) { |
4 | Int min = null; |
5 | if (startsWith(s, "#")) null; |
6 | patLoop: for (S pat : tok_splitAtComma(patterns)) { |
7 | if (startsWith(pat, "#")) continue; // ignore special commands |
8 | int score = 0; |
9 | for (S phrase : tok_splitAtPlus(pat)) { |
10 | if (endsWith(phrase, "!")) { |
11 | if (!find3(phrase, s)) continue patLoop; |
12 | } else { |
13 | Int score2 = find3_levenWithSwapsDistance(phrase, s); |
14 | if (score2 == null) continue patLoop; |
15 | score += score2; |
16 | } |
17 | } |
18 | min = min_withNull(min, score); |
19 | } |
20 | ret min; |
21 | } |
Began life as a copy of #1026018
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1026037 |
Snippet name: | mmo_levenWithSwapsScore - like mmo_match, but return leven difference |
Eternal ID of this version: | #1026037/6 |
Text MD5: | a42efe94dded7324a61b86e683427cb3 |
Transpilation MD5: | 203d1adea6d7898307b97034d4179ef3 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-01-05 04:15:38 |
Source code size: | 737 bytes / 21 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 227 / 363 |
Version history: | 5 change(s) |
Referenced in: | [show references] |