Libraryless. Click here for Pure Java version (3376L/21K).
persistable sclass NLABlock { S text; // original text LS lines; // same, split into lines Set<Entity> entities; // entities L<Line> parsedLines; class Line { S text; Entity introducedEntity; L proposition; // fragments *() {} *(S *text) {} *(S *text, L *proposition) {} toString { ret joinWithSpace(proposition) + (introducedEntity == null ? "" : " => " + introducedEntity); } int index() { ret parsedLines.indexOf(this); } } sclass Entity extends Cluster { Line definedInLine; O userObject; *(S name, Line *definedInLine) { this(name); if (definedInLine != null) definedInLine.introducedEntity = this; } *(S name) { addSynonym(name); } } *(S *text) {} bool isParsed() { ret parsedLines != null; } toString { ret !isParsed() ? text : lines_rtrim(parsedLines); } L<Line> introductions() { ret filter(parsedLines, line -> line.introducedEntity != null); } L<Line> propositionLines() { ret filter(parsedLines, line -> line.introducedEntity == null); } Set<L> propositionSet() { ret collectAsSet proposition(propositionLines()); } Map<L, Line> propositionIndex() { ret indexByField proposition(propositionLines()); } }
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1028734 |
Snippet name: | NLABlock - block of Natural Language Assembly with interpretations |
Eternal ID of this version: | #1028734/27 |
Text MD5: | 87918e9e4675aa71811beb5646f18330 |
Transpilation MD5: | 68bee8403e841addbe5584ae3fbb74fb |
Author: | stefan |
Category: | javax / nla |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-10 15:07:55 |
Source code size: | 1359 bytes / 58 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 346 / 753 |
Version history: | 26 change(s) |
Referenced in: | [show references] |