Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

50
LINES

< > BotCompany Repo | #1010122 // AI's First JavaX Program - AI generates a mini-program from 3 diagrams [OK]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 4489K of libraries. Click here for Pure Java version (15458L/113K).

1  
!7
2  
3  
static L<S> inputDiagrams = tlft([=[
4  
  CirclesAndLines(circles=[Circle(quickvis="A JavaX Program", text="A JavaX Program", x=d("0.28674351585014407"), y=d("0.20889748549323017")), Circle(text="a translator invocation", x=d("0.6801152737752162"), y=d("0.20889748549323017")), Circle(text="a main program", x=d("0.6801152737752162"), y=d("0.6015473887814313"))], lines=[Arrow(a=t5, b=t30, text="consists of"), Arrow(a=t30, b=t51, text="and")])
5  
  CirclesAndLines(circles=[Circle(text="a typical translator invocation", x=d("0.3746397694524496"), y=d("0.4700193423597679")), Circle(text="[[!7]]", x=d("0.7896253602305475"), y=d("0.4700193423597679"))], lines=[Arrow(a=t5, b=t26, text="is")])
6  
  CirclesAndLines(circles=[Circle(text="an example main program", x=d("0.49135446685878964"), y=d("0.195357833655706")), Circle(text="[[p { infoBox(\"Hello world!\"); }]]", x=d("0.4899135446685879"), y=d("0.5918762088974855"))], lines=[Arrow(a=t5, b=t26, text="is")])
7  
]=]);
8  
9  
static new Var<S> code;
10  
11  
p {
12  
  // Prepare & Reason
13  
  
14  
  Web web = webFromCALStructures_vis(inputDiagrams);
15  
  web_dropSecondWord(web, "typical");
16  
  web_dropSecondWord(web, "example");
17  
  web_replaceFirstWord(web, "an", "a");
18  
  web_mergeNodes(web);
19  
  web_collapseBackwardsWithName(web, "is");
20  
  
21  
  // Make Program
22  
  
23  
  WebNode program = assertNotNull("Program Node", web_nodeWithLastWord(web, "Program"));
24  
25  
  WebNode n = web_findForwardRelated(program, "consists of");
26  
  new L<S> parts;
27  
  if (n != null) do ping {
28  
    parts.add(unquote(n.text()));
29  
  } while ((n = web_findForwardRelated(n, "and")) != null);
30  
  code.set(join("\n\n", parts));
31  
  
32  
  // Show
33  
34  
  magellan(); cal_lineLength(45);
35  
  CirclesAndLines.defaultBackgroundImageID = #1009675; //#1009676
36  
  frameIcon(#1010138, centerFrame(650, 500, showTabbedWebs(0,
37  
    "User Input 1", webFromCALStructure(get(inputDiagrams, 0)),
38  
    "User Input 2", webFromCALStructure(get(inputDiagrams, 1)),
39  
    "User Input 3", webFromCALStructure(get(inputDiagrams, 2)),
40  
    "Computed Web", web,
41  
    "Generated Program", centerAndNorth(
42  
      withMargin(20, withTitle(setFontSize(20, jlabel("The Code")), setFontSize(20, bindTextAreaToVar(code, jtypewritertextarea())))),
43  
      withMargin(jcenteredline(setFontSize(20, jbutton("Compile & Run!", f runProgram))))))));
44  
  thread { loading " Precompiling... " { veryQuickJava(dropTranslators(code!)); }} // precompile
45  
  hideConsole();
46  
}
47  
48  
svoid runProgram {
49  
  thread { loading { callMain(veryQuickJava(dropTranslators(code!))); } }
50  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, imzmzdywqqli, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1010122
Snippet name: AI's First JavaX Program - AI generates a mini-program from 3 diagrams [OK]
Eternal ID of this version: #1010122/58
Text MD5: c8f8ef2a17a4bcca15a3be3eb9fb6498
Transpilation MD5: 37d2a6d2862e1f41c56d215280068807
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-09-04 02:49:01
Source code size: 2529 bytes / 50 lines
Pitched / IR pitched: No / No
Views / Downloads: 621 / 1319
Version history: 57 change(s)
Referenced in: [show references]