Libraryless. Click here for Pure Java version (18227L/129K).
!7 sclass MatchInput > DynPrintLogWithInput { start { dm_requireModule("#1016073/MechLists"); useLocalMechListCopies(true); set serverMechList_raw_fresh_verbose; } void update(S s) { print("\n> " + s); L<S> pats = mL("English sentence patterns"); L<S> tok = javaTokWithAngleBracketsC(s); printStruct(tok); PlanInMotion<S> plan = new(pats); //L<Pair<S, L<Pair<S>>>> results = new L; // pattern + match PriorityQueue<Pair<S, L<Pair<S>>>> results = new PriorityQueue<Pair<S, L<Pair<S>>>>(new Comparator<Pair<S, L<Pair<S>>>>() { public int compare(Pair<S, L<Pair<S>>> a, Pair<S, L<Pair<S>>> b) { //print("cmp " + l(a.b) + " " + l(b.b)); ret cmp(l(a.b), l(b.b)); } }); for (S pat : plan.master()) { L<S> tokPat; tokPat = javaTokWithAngleBracketsC(pat); L<Pair<S>> match = uniquify(dropTwinPairsIC(zipTwoListsToPairs_ifSameLength(tokPat, tok))); if (match != null) { print(" Result: Choose pattern " + quote(pat) + " for input " + quote(s) + " if match: " + sfu(match)); results.add(pair(pat, match)); } } pnlStruct(mapPairB(f l, priorityQueueToList(results)); for (Pair<S, L<Pair<S>>> p : priorityQueueToList(results)) { L<S> match = antiFilter(f parsing_checkMatchPairUsingMechList, p.b); if (l(match) < l(p.b)) print(" Reduced match to: " + sfu(match)); } } }
Began life as a copy of #1017192
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017199 |
Snippet name: | Match Input With Pattern v2 [Dyn Module, dev.] |
Eternal ID of this version: | #1017199/16 |
Text MD5: | 76391812336f8bed7c6548e26c64e47c |
Transpilation MD5: | cfb86847f3d0847771d8c8dcb6379863 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-07-13 20:26:52 |
Source code size: | 1481 bytes / 41 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 418 / 567 |
Version history: | 15 change(s) |
Referenced in: | #1017205 - Match Input With Pattern v3 [Dyn Module, dev.] |