Libraryless. Click here for Pure Java version (18515L/132K).
1 | !7 |
2 | |
3 | sclass MatchInput > DynPrintLogWithInput { |
4 | start { dm_useLocallyCopiedMechLists(); } |
5 | |
6 | void update(S s) { |
7 | print("\n> " + s); |
8 | L<S> tokInput = printStruct(javaTokWithAngleBracketsC(s)); |
9 | new L<ParseResult1> results; |
10 | |
11 | // Try matching pattern & input word-by-word |
12 | for (S pat : mech_englishSentencePatterns()) |
13 | ai_matchAngleBracketPattern_toParseResults(javaTokWithAngleBracketsC_addNumbers(pat), tokInput, results); |
14 | |
15 | // Try expanding patterns |
16 | for (S pat : mech_englishSentencePatterns()) |
17 | ai_matchAngleBracketPattern_spread_toParseResults(javaTokWithAngleBracketsC_addNumbers(pat), tokInput, results); |
18 | |
19 | // Go through sorted results, try to solve assumptions using subsolve |
20 | for (ParseResult1 p : parseResultsByNumberOfAssumptions(results)) { |
21 | new L<PairS> verified; |
22 | for (PairS assumption : p.assumptions) { |
23 | S category = assumption.a, phrase = assumption.b; |
24 | if (eq(category, "<noun>")) |
25 | for (S pat : mL("Noun phrase patterns")) { |
26 | LPairS match = ai_matchAngleBracketPattern(javaTokWithAngleBracketsC_addNumbers(pat), javaTokWithAngleBracketsC(phrase)); |
27 | if (match != null && empty(match)) { |
28 | //print("Verified: " + assumption); |
29 | verified.add(assumption); |
30 | } |
31 | } |
32 | } |
33 | addIfNotNull(results, parseResultWithVerifiedAssumptions(p, verified)); |
34 | } |
35 | |
36 | for (ParseResult1 p : takeFirst(10, parseResultsByNumberOfAssumptions(results))) |
37 | print(" [" + l(p.assumptions) + "] " + joinNemptiesWithComma(ai_renderMatchWithQuestionMarks(p.assumptions), ai_renderMatch(p.matches)) + " | pattern " + quote(joinWithSpace(p.pat)) + " for input " + quote(joinWithSpace(p.input))); |
38 | |
39 | if (l(results) > 10) print("[" + (l(results)-10) + " more]"); |
40 | } |
41 | } |
Began life as a copy of #1017290
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: | #1017297 |
Snippet name: | Match Input With Pattern v6 (with ParseResult1, OK) |
Eternal ID of this version: | #1017297/16 |
Text MD5: | fff6bec5b2c068fc97cf176a037e5f8d |
Transpilation MD5: | 09c2fd4b134ec55a5a9325d7c0203f45 |
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-16 16:20:47 |
Source code size: | 1859 bytes / 41 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 442 / 638 |
Version history: | 15 change(s) |
Referenced in: | [show references] |