Libraryless. Click here for Pure Java version (7142L/48K/158K).
1 | !7 |
2 | |
3 | concept AIConcept {
|
4 | S globalID = aGlobalID(); |
5 | S name; |
6 | S comment; |
7 | } |
8 | |
9 | concept C {
|
10 | S globalID = aGlobalID(); |
11 | S name; |
12 | S comment; |
13 | new Ref<C> type; |
14 | new LinkedHashMap<C, C> slots; |
15 | |
16 | public S toString() {
|
17 | ret name; |
18 | } |
19 | } |
20 | |
21 | static C findCOpt(S name) {
|
22 | ret findConcept(C, +name); |
23 | } |
24 | |
25 | static C findC(S name) {
|
26 | C c = findCOpt(name); |
27 | assertNotNull(name, c); |
28 | ret c; |
29 | } |
30 | |
31 | static C intC(int i) {
|
32 | C c = findCOpt(str(i)); |
33 | if (c == null) {
|
34 | c = instance("Integer");
|
35 | cset(c, name := str(i)); |
36 | } |
37 | ret c; |
38 | } |
39 | |
40 | static C instance(S name) {
|
41 | ret cnew(C, type := findC(name)); |
42 | } |
43 | |
44 | static C getC(C parent, C slot) {
|
45 | ret parent == null ? null : parent.slots.get(slot); |
46 | } |
47 | |
48 | static C getC(C parent, S slot) {
|
49 | ret parent == null ? null : parent.slots.get(findC(slot)); |
50 | } |
51 | |
52 | static void setC(C parent, C slot, C value) {
|
53 | parent.slots.put(slot, value); |
54 | } |
55 | |
56 | static void setC(C parent, S slot, C value) {
|
57 | setC(parent, findC(slot), value); |
58 | } |
59 | |
60 | p {
|
61 | conceptsAndBot(); |
62 | Concepts in = new Concepts(#1006463).load(); // load AIConcept's |
63 | |
64 | L<AIConcept> imported = list(in, AIConcept); |
65 | print("Have AI concepts: " + struct(collect(imported, "name")));
|
66 | for (AIConcept c : imported) {
|
67 | C cc = findConcept(C, globalID := c.globalID); |
68 | if (cc == null) {
|
69 | print("Importing " + c.name);
|
70 | uniq(C, globalID := c.globalID, name := c.name, comment := c.comment); |
71 | } |
72 | } |
73 | |
74 | C img = findConcept(C, type := findC("RGB Image"));
|
75 | if (img == null) {
|
76 | print("Making image.");
|
77 | img = instance("RGB Image");
|
78 | } |
79 | C width = getC(img, "Width"); |
80 | print("Width: " + width);
|
81 | if (width == null) |
82 | setC(img, "Width", intC(200)); |
83 | C height = getC(img, "Height"); |
84 | print("Height: " + height);
|
85 | if (height == null) |
86 | setC(img, "Height", intC(100)); |
87 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1006464 |
| Snippet name: | Concept Graphs [dev.] |
| Eternal ID of this version: | #1006464/1 |
| Text MD5: | 2ccd1c8158a29d4da1c5811cd332000a |
| Transpilation MD5: | 7c5def958e07afd087113fb13fb8b66a |
| Author: | stefan |
| Category: | javax / gui / concepts |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-01-05 21:23:51 |
| Source code size: | 1858 bytes / 87 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 684 / 849 |
| Referenced in: | [show references] |