Libraryless. Click here for Pure Java version (18221L/130K).
1 | !7 |
2 | |
3 | sclass MatchInput > DynPrintLogWithInput {
|
4 | start { dm_useLocallyCopiedMechLists(); }
|
5 | |
6 | void update(S s) {
|
7 | print("\n> " + s);
|
8 | L<S> pats = mL("English sentence patterns");
|
9 | L<S> tok = javaTokWithAngleBracketsC(s); |
10 | printStruct(tok); |
11 | PlanInMotion<S> plan = new(pats); |
12 | L<Pair<S, L<Pair<S>>>> results = new L; // pattern + match |
13 | for (S pat : plan.master()) {
|
14 | L<S> tokPat; |
15 | tokPat = javaTokWithAngleBracketsC(pat); |
16 | L<Pair<S>> match = uniquify(dropTwinPairsIC(zipTwoListsToPairs_ifSameLength(tokPat, tok))); |
17 | if (match != null) {
|
18 | print(" Result: Choose pattern " + quote(pat) + " for input " + quote(s) + " if match: " + sfu(match));
|
19 | results.add(pair(pat, match)); |
20 | } |
21 | } |
22 | |
23 | // reduce from mech lists |
24 | for (Pair<S, L<Pair<S>>> p : results) {
|
25 | L<Pair<S>> match = antiFilter(f parsing_checkMatchPairUsingMechList, p.b); |
26 | if (l(match) < l(p.b)) {
|
27 | print(" Reduced match to: " + sfu(match));
|
28 | p.b = match; |
29 | } |
30 | } |
31 | |
32 | print(); |
33 | pnlStruct(sortedByComparator(results, (Comparator) lengthOfPairBListComparator())); |
34 | } |
35 | } |
Began life as a copy of #1017199
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1017205 |
| Snippet name: | Match Input With Pattern v3 [Dyn Module, dev.] |
| Eternal ID of this version: | #1017205/6 |
| Text MD5: | b0fabe413c772cf8dedc775682f665a6 |
| Transpilation MD5: | 363eb251fe59eb9070ebbda63b81a6e9 |
| 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-14 02:03:04 |
| Source code size: | 1172 bytes / 35 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 697 / 905 |
| Version history: | 5 change(s) |
| Referenced in: | [show references] |