1 | // Someone's name |
2 | concept Name { |
3 | S name; |
4 | } |
5 | |
6 | // A person (human or computer) |
7 | concept Person {} |
8 | |
9 | // link a person to a name |
10 | concept Person2Name { |
11 | new Ref<Person> person; |
12 | new Ref<Name> name; |
13 | bool usable = true; |
14 | } |
15 | |
16 | // our user |
17 | Person > User {} |
18 | |
19 | // myself |
20 | Person > Me {} |
21 | |
22 | // A line typed by user or bot |
23 | concept Line { |
24 | S text; |
25 | new Ref<Person> author; |
26 | new Ref<LineIdea> idea; // the interpretation we settled on |
27 | |
28 | *() {} |
29 | *(Person a, S *text) { author.set(a); } |
30 | *(S *text, LineIdea idea) { this.idea.set(idea); } |
31 | *(S *text, Class<? extends LineIdea> idea) { this.idea.set(uniq(idea)); } |
32 | } |
33 | |
34 | // A line interpretation |
35 | concept LineIdea {} |
36 | |
37 | // Bot error |
38 | LineIdea > LError { |
39 | S stackTrace; |
40 | |
41 | *() {} |
42 | *(Throwable e) { stackTrace = getStackTrace(e); change(); } |
43 | } |
44 | |
45 | // "test" |
46 | LineIdea > LTest {} |
47 | |
48 | // repeating another line |
49 | LineIdea > LRepeating {} |
50 | |
51 | // A greeting ("hello X") |
52 | LineIdea > LGreet { |
53 | new Ref<Person2Name> name; |
54 | |
55 | *() {} |
56 | *(Person2Name n) { name.set(n); } |
57 | } |
58 | |
59 | // base class for questions |
60 | LineIdea > LQuestion {} |
61 | |
62 | // "What is your name?" |
63 | LQuestion > LWhatsYourName {} |
64 | |
65 | // "I don't understand" |
66 | LineIdea > LIDontUnderstand {} |
67 | |
68 | // I have nothing to say |
69 | LineIdea > LLalala {} |
70 | |
71 | // "My name is X" |
72 | LineIdea > LMyNameIs { |
73 | new Ref<Name> name; |
74 | } |
75 | |
76 | // A specific question/answer pair |
77 | concept QA_WhatsYourName_MyNameIs { |
78 | new Ref<Line> q; |
79 | new Ref<Line> a; |
80 | } |
81 | |
82 | LineIdea > LAskMeSomething {} |
83 | |
84 | // Wrap a bug during processing of user input |
85 | LineIdea > LBug { |
86 | S stackTrace; |
87 | |
88 | *() {} |
89 | *(Throwable e) { stackTrace = getStackTrace(e); change(); } |
90 | } |
91 | |
92 | // We couldn't interpret a line yet |
93 | LineIdea > LUnknown {} |
94 | |
95 | LineIdea > LIDontKnowWhatToAskYou {} |
96 | |
97 | LineIdea > LGreetMe {} |
98 | |
99 | LineIdea > LISee {} |
100 | |
101 | concept Dialog { |
102 | new RefL<Line> lines; |
103 | } |
104 | |
105 | static Dialog dialog() { ret unique(Dialog); } |
106 | static User user() { ret uniq(User); } |
107 | static Me me() { ret uniq(Me); } |
108 | |
109 | static L<Person2Name> usableNames(Person p) { |
110 | ret list(Person2Name, "usable", true, "person", p); |
111 | } |
Began life as a copy of #1005284
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: | #1005291 |
Snippet name: | User's Name 2 [Include] |
Eternal ID of this version: | #1005291/1 |
Text MD5: | 77a34d068fa636e08a08c5ba7898fced |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-10-30 19:17:34 |
Source code size: | 2080 bytes / 111 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 597 / 578 |
Referenced in: | [show references] |