Libraryless. Click here for Pure Java version (5853L/38K/126K).
!752 concepts. concept Imperative { new Ref v; // verb new Ref o; // object } concept Measurement { new Ref x; // e.g. "all" new Ref y; // e.g. "programs" } concept Addition { new Ref x; // e.g. "programs" new Ref prep; // preposition, e.g. "with" new Ref z; // e.g. "a large number of files" } static Map<S, Class> rules = litorderedmap( "(find) *" := Imperative, "(all|a) *" := Measurement, "* (called|with) *" := Addition ); p { testParse([[Find all programs with a file called "concepts.structure"]]); } sbool properSentence(Concept c) { if (!c << Imperative || neq(c/Imperative.v, cstr("find"))) false; c = c/Imperative.o!; ret matchCstr("all programs with a file called *", c); //if (!c << Measurement || neq(c/Measurement.x, cstr("all"))) false; //c = c/Measurement.y; } !include #1005497 // testParse + parseToOptions using unrollOptions static void parse(S s, Collector<Concept> out) { new Matches m; for (S pattern : keys(rules)) if (flexMatchIC2(pattern, s, m)) ret if out.add(conceptFromMatches(rules.get(pattern), m)); out.add(cstr(s)); // default }
Began life as a copy of #1005502
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005508 |
Snippet name: | Parse Sentence Multi 5, using rules [WORKS] |
Eternal ID of this version: | #1005508/1 |
Text MD5: | b887ab736f382e72cc0a7c694c1465da |
Transpilation MD5: | 5b59bc5e8557bb97641a458df19acc7e |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-11-24 00:26:06 |
Source code size: | 1167 bytes / 47 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 556 / 612 |
Referenced in: | -