Libraryless. Click here for Pure Java version (5913L/38K/127K).
!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" } 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(quick(Imperative, m)); if (flexMatchStartIC(ll("all", "a"), s, m)) ret if out.add(quick(Measurement, m)); if (flexMatchIC2("* (called|with) *", s, m)) ret if out.add(quick(Addition, m)); out.add(cstr(s)); // default } static Concept quick(Class<? extends Concept> cClass, Matches m) { Concept c = cnew(cClass); S order = toStringOpt(getOpt(cClass, "_fieldOrder")); L<S> fields; if (order != null) fields = splitAtSpace(order); else fields = asList(asTreeSet(conceptFields(c))); if (l(fields) != l(m.m)) fail(struct(fields) + " / " + struct(m.m)); for i over fields: cset(c, fields.get(i), parseToOptions(m.unq(i))); ret c; }
Began life as a copy of #1005487
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: | #1005502 |
Snippet name: | Parse Sentence Multi 4, using (a|b) syntax [works] |
Eternal ID of this version: | #1005502/1 |
Text MD5: | c2914e61cd3be96df13dd2fb464d1edf |
Transpilation MD5: | f1c6d0e6ed10222671b4d89c0e3d0d66 |
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:13:45 |
Source code size: | 1613 bytes / 63 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 514 / 586 |
Referenced in: | [show references] |