Libraryless. Click here for Pure Java version (4010L/24K).
// usually returns value from 0 to 1 (possibly higher values too depending on pattern) static double mmo2_scoredMatch(MMOPattern pattern, S s) { ret mmo2_scoredMatch(pattern, s, false, false); } static double mmo2_scoredMatch(MMOPattern pattern, S s, bool startOfLine, bool endOfLine) { ifdef mmo2_scoredMatch_debug printFunctionCall mmo2_scoredMatch(pattern, s, startOfLine, endOfLine); endifdef if (pattern == null) ret 0; S s2 = trim(s); if (pattern cast MMOPattern.StartOfLine) ret mmo2_scoredMatch(pattern.p, s2, true, endOfLine); if (pattern cast MMOPattern.EndOfLine) ret mmo2_scoredMatch(pattern.p, s2, startOfLine, true); if (pattern cast MMOPattern.Phrase) ret mmo2_match(pattern, s, startOfLine, endOfLine) ? 1 : 0; if (pattern cast MMOPattern.And) ret doubleProduct(map(pattern.l, pat -> mmo2_scoredMatch(pat, s2, startOfLine, endOfLine))); if (pattern cast MMOPattern.Or) ret doubleMax(map(pattern.l, pat -> mmo2_scoredMatch(pat, s2, startOfLine, endOfLine))); if (pattern cast MMOPattern.Not) ret invertZeroToOne(mmo2_scoredMatch(pattern.p, s2, startOfLine, endOfLine)); if (pattern cast MMOPattern.Weighted) ret mmo2_scoredMatch(pattern.p, s2, startOfLine, endOfLine)*pattern.weight; fail("what. " + pattern); } static double mmo2_scoredMatch(S pattern, S s) { ret mmo2_scoredMatch(mmo2_parsePattern(pattern), s); }
Began life as a copy of #1028074
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1028082 |
Snippet name: | mmo2_scoredMatch [dev.] |
Eternal ID of this version: | #1028082/7 |
Text MD5: | e130182ee13ef4895e21c333edc02596 |
Transpilation MD5: | f78f69ed78ecf3f83e01a29b22e3b3a6 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-05-17 15:53:28 |
Source code size: | 1422 bytes / 31 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 191 / 280 |
Version history: | 6 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |