Libraryless. Click here for Pure Java version (3290L/23K/74K).
!7 // np = noun phrase // q = question word // vb = verb phrase // adj = adjective static SS data = litmap( "Commodore", "np", "Commodore 64", "np", "Amiga", "np", "Atari", "np", "Atari ST", "np", "What", "q", "Where", "q", "How", "q", "Why", "q", "When", "q", "is", "vb", "are", "vb", "wants", "vb", "does", "vb", "goes", "vb", "fast", "adj", "slow", "adj", "new", "adj", "old", "adj", "<q> <vb> <np>", "question", ); static O parser; p { parser = hotwire("#1002719"); print(parse("What is Amiga")); makeBot(); } static S parse(S text) { S rules = makeRules(); O result; time { result = call(parser, "parse", text, rules); } //ret "```" + call(result, "prettierAnalysis") + "```"; //ret structure(call(result, "explain", explainClass)); L<S> classes = cast call(result, "fullMatchClasses"); ret (empty(classes) ? "not parsed" : "parsed as " + structure(classes)) + " [" + getLastTiming() + " ms, " + getOpt(parser, "timing") + " ms actual]"; } static S makeRules() { ret fromLines(map(data, func(S s, S c) { s + " = " + c })); } synchronized static S answer(S s) { ret parse(s); }
Began life as a copy of #1005313
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005314 |
Snippet name: | Destructuring Text Using Bottom-Up Parser [does something] |
Eternal ID of this version: | #1005314/4 |
Text MD5: | 8602a3a86003670d0bb40eeb5e48a3b7 |
Transpilation MD5: | 574cdb6b8f9db5f9b94cc08d16d427ef |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-05-24 22:35:01 |
Source code size: | 1222 bytes / 59 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 418 / 508 |
Version history: | 3 change(s) |
Referenced in: | -