Libraryless. Click here for Pure Java version (15441L/112K).
!7 srecord Line ( S type, // 'user, 'suggestion, 'bot, 'eval, 'evalResult, 'metaComment S text ) {} concept Interaction { new L<Line> lines; bool current; void addLine(Line line) { lines.add(line); change(); } } sS lineToString(Line line) { ret lpad(10, firstToUpper(replaceCompleteValue(line.type, 'metaComment, 'comment))) + ": " + line.text; } module TrainInteraction { bool watchEvals; transient S imageID = #1101205; transient JTextArea taInteraction; transient S log; transient JTextField tfInput, tfToSay, tfMeta; transient JLabel lblOutput; transient Interaction current; start { db(); current = uniq_sync(Interaction, current := true); log = lines(map lineToString(current.lines)); dm_vmBus_onMessage('javaEval_starting, voidfunc(S code, bool realEval) { if (watchEvals) addLine(Line('eval, code)); }); for (S msg : ll('javaEval_OK, 'javaEval_error)) dm_vmBus_onMessage(msg, voidfunc(S code, O result) { if (watchEvals) addLine(Line('evalResult, shorten(str(result), 1024))); }); } visualize { onEnter(tfInput = jTextField(), r { addLine(Line('user, gtt(tfInput))) }); onEnter(tfToSay = jTextField(), r { addLine(Line('suggestion, gtt(tfToSay))) }); onEnter(tfMeta = jTextField(), r { addLine(Line('metaComment, gtt(tfMeta))) }); taInteraction = dm_fieldTextArea('log); ret centerAndSouth( centerAndSouthWithMargins( westAndCenterWithMargin(jimage(imageID), taInteraction), northAndCenterWithMargin( fontSize(20, lblOutput = jCenteredBoldLabel(" ")), makeForm3( "Your input:", focusOnShow(fontSize(16, tfInput)), "Make me say:", fontSize(16, tfToSay), "Make a meta-comment:", fontSize(16, tfMeta)) )), westAndCenterWithMargins( dm_fieldCheckBox('watchEvals), rightAlignedButtons("Start Over", rThread { if (empty(current.lines) || confirmOKCancel("Sure?")) { cset(current, lines := new L); setField(log := ""); } }, "Save Interaction", rThread { dm_call(dm_makeOrShowModule("#1020418/TrainedInteractions"), 'addInteraction, current); cset(current, current := false); current = uniq_sync(Interaction, current := true); setField(log := ""); }))); } Line addLine(Line line) { current.addLine(line); setField(log := log + lineToString(line) + "\n"); ret line; } }
Began life as a copy of #1019675
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020415 |
Snippet name: | Train Interaction [dev.] |
Eternal ID of this version: | #1020415/34 |
Text MD5: | a71b0ae535446de1819307ca20e5482c |
Transpilation MD5: | 13ef5401984c10f0bd58cde5e83739a1 |
Author: | stefan |
Category: | javax / stefan's os / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-20 22:03:28 |
Source code size: | 2679 bytes / 91 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 376 / 1651 |
Version history: | 33 change(s) |
Referenced in: | [show references] |