Libraryless. Click here for Pure Java version (18515L/132K).
!7 sclass MatchInput > DynPrintLogWithInput { start { dm_useLocallyCopiedMechLists(); } void update(S s) { print("\n> " + s); L<S> tokInput = printStruct(javaTokWithAngleBracketsC(s)); new L<ParseResult1> results; // Try matching pattern & input word-by-word for (S pat : mech_englishSentencePatterns()) ai_matchAngleBracketPattern_toParseResults(javaTokWithAngleBracketsC_addNumbers(pat), tokInput, results); // Try expanding patterns for (S pat : mech_englishSentencePatterns()) ai_matchAngleBracketPattern_spread_toParseResults(javaTokWithAngleBracketsC_addNumbers(pat), tokInput, results); // Go through sorted results, try to solve assumptions using subsolve for (ParseResult1 p : parseResultsByNumberOfAssumptions(results)) { new L<PairS> verified; for (PairS assumption : p.assumptions) { S category = assumption.a, phrase = assumption.b; if (eq(category, "<noun>")) for (S pat : mL("Noun phrase patterns")) { LPairS match = ai_matchAngleBracketPattern(javaTokWithAngleBracketsC_addNumbers(pat), javaTokWithAngleBracketsC(phrase)); if (match != null && empty(match)) { //print("Verified: " + assumption); verified.add(assumption); } } } addIfNotNull(results, parseResultWithVerifiedAssumptions(p, verified)); } for (ParseResult1 p : takeFirst(10, parseResultsByNumberOfAssumptions(results))) print(" [" + l(p.assumptions) + "] " + joinNemptiesWithComma(ai_renderMatchWithQuestionMarks(p.assumptions), ai_renderMatch(p.matches)) + " | pattern " + quote(joinWithSpace(p.pat)) + " for input " + quote(joinWithSpace(p.input))); if (l(results) > 10) print("[" + (l(results)-10) + " more]"); } }
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: | 441 / 636 |
Version history: | 15 change(s) |
Referenced in: | [show references] |