Libraryless. Click here for Pure Java version (4012L/24K).
sbool mmo2_match(MMOPattern pattern, S s) { ret mmo2_match(pattern, s, false, false); } sbool mmo2_match(MMOPattern pattern, S s, bool startOfLine, bool endOfLine) { ifdef mmo2_match_debug printFunctionCall mmo2_match_debug(pattern, s, startOfLine, endOfLine); endifdef if (pattern == null) false; S s2 = trim(s); if (pattern cast MMOPattern.StartOfLine) ret mmo2_match(pattern.p, s2, true, endOfLine); if (pattern cast MMOPattern.EndOfLine) ret mmo2_match(pattern.p, s2, startOfLine, true); if (pattern cast MMOPattern.Phrase) { S p = pattern.phrase; if (pattern.quoted) ret cicWithSmartWordBoundary(s2, p); if (startsWith(p, "#")) ret eqic(p, s2); ret match3_startOrEndOfLine(p, s2, startOfLine, endOfLine); } if (pattern cast MMOPattern.And) ret all(pattern.l, pat -> mmo2_match(pat, s2, startOfLine, endOfLine)); if (pattern cast MMOPattern.Or) ret any(pattern.l, pat -> mmo2_match(pat, s2, startOfLine, endOfLine)); if (pattern cast MMOPattern.Not) ret !mmo2_match(pattern.p, s2, startOfLine, endOfLine); fail("what. " + pattern); } sbool mmo2_match(S pattern, S s) { ret mmo2_match(mmo2_parsePattern(pattern), s); }
Began life as a copy of #1026500
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1028074 |
Snippet name: | mmo2_match - current "PhraseCache" matcher for chat bots |
Eternal ID of this version: | #1028074/13 |
Text MD5: | 8dc51ac813eaae5d63e7211e53f672c4 |
Transpilation MD5: | 0d25628f71dddd10354aa17c16fc0592 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-11-02 12:43:06 |
Source code size: | 1222 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 312 / 921 |
Version history: | 12 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1028082 - mmo2_scoredMatch [dev.] #1030322 - mmo2_matchWithTypos |