Libraryless. Click here for Pure Java version (5792L/37K/125K).
!752 concepts. concept Imperative { new Ref v; // verb new Ref o; // object sS _fieldOrder = "v o"; } 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" sS _fieldOrder = "x prep z"; } 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; if (flexMatchStartIC(ll("find"), s, m)) ret if out.add(cnew(Imperative, v := cstr($1), o := parseToOptions($2))); if (flexMatchStartIC(ll("all", "a"), s, m)) ret if out.add(cnew(Measurement, x := cstr($1), y := parseToOptions($2))); for (S prep : ll("called", "with")) if (flexMatchIC("* \*prep*/ *", s, m)) ret if out.add(cnew(Addition, x := parseToOptions($1), prep : = cstr(prep), z := parseToOptions($2))); out.add(cstr(s)); // default }
Began life as a copy of #1005485 Possible shortening: "(find) *" => Imperative "(all|a) *" => Measurement "* (called|with) *" => Addition
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: | #1005487 |
Snippet name: | Parse Sentence Multi 3, unrollOptions [works] |
Eternal ID of this version: | #1005487/1 |
Text MD5: | f9a20dabb2ee9ca0d8267be1b7e2141f |
Transpilation MD5: | 04cb194aabbeecbc73d472fb9e634acf |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-11-23 22:42:47 |
Source code size: | 1456 bytes / 60 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 476 / 532 |
Referenced in: | #1005502 - Parse Sentence Multi 4, using (a|b) syntax [works] |