Libraryless. Click here for Pure Java version (3376L/21K).
1 | persistable sclass NLABlock { |
2 | S text; // original text |
3 | LS lines; // same, split into lines |
4 | Set<Entity> entities; // entities |
5 | L<Line> parsedLines; |
6 | |
7 | class Line { |
8 | S text; |
9 | Entity introducedEntity; |
10 | L proposition; // fragments |
11 | |
12 | *() {} |
13 | *(S *text) {} |
14 | *(S *text, L *proposition) {} |
15 | |
16 | toString { |
17 | ret joinWithSpace(proposition) |
18 | + (introducedEntity == null ? "" : " => " + introducedEntity); |
19 | } |
20 | |
21 | int index() { ret parsedLines.indexOf(this); } |
22 | } |
23 | |
24 | sclass Entity extends Cluster { |
25 | Line definedInLine; |
26 | O userObject; |
27 | |
28 | *(S name, Line *definedInLine) { |
29 | this(name); |
30 | if (definedInLine != null) definedInLine.introducedEntity = this; |
31 | } |
32 | *(S name) { addSynonym(name); } |
33 | } |
34 | |
35 | *(S *text) {} |
36 | |
37 | bool isParsed() { ret parsedLines != null; } |
38 | |
39 | toString { |
40 | ret !isParsed() ? text : lines_rtrim(parsedLines); |
41 | } |
42 | |
43 | L<Line> introductions() { |
44 | ret filter(parsedLines, line -> line.introducedEntity != null); |
45 | } |
46 | |
47 | L<Line> propositionLines() { |
48 | ret filter(parsedLines, line -> line.introducedEntity == null); |
49 | } |
50 | |
51 | Set<L> propositionSet() { |
52 | ret collectAsSet proposition(propositionLines()); |
53 | } |
54 | |
55 | Map<L, Line> propositionIndex() { |
56 | ret indexByField proposition(propositionLines()); |
57 | } |
58 | } |
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: | 348 / 757 |
Version history: | 26 change(s) |
Referenced in: | [show references] |