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

81
LINES

< > BotCompany Repo | #1011156 // Auto GAC 2 [OK, with confirming parses]

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

Download Jar. Libraryless. Click here for Pure Java version (16369L/117K).

!7

sbool simplify = true;
sS background = #1009946;
static JDesktopPane desktop;
static ShadowJLabel lblInput;
static JLabel lblSpoiler;
static Canvas canvas;
static JButton btnParseOK, btnParseNotOK;
sbool auto = true;
static Bool parseOK;
static S input;
static Triple<S> triple;

static Map<Pair<S, Triple<S>>, Bool> parseOKMap;

p {
  parseOKMap = persistentHashMap('parseOKMap);
  autoRestart();
  nimbus();
  gac36k(); // preload
  desktop = jTiledBackgroundDesktopPane(background);
  autoFixDesktopPane(desktop);
  cleanExitOnFrameClose(showMaximizedFrame(desktop));
    
  lblInput = centerLabel(swingNu(ShadowJLabel));
  lblInput.setForeground(Color.yellow);
  lblInput.setRightShadow(2, 3, Color.gray);
  
  setInternalFrameY(40, showCenteredInternalFrame(desktop, "Question", desktop.getWidth()-100, 150, 
    jBackground(Color.black, withBottomMargin(4, centerAndSouth(
      jbold(setFont(#1011146, 35, lblInput)),
      westAndEast(
        withLeftMargin(10, setBoldFontSize(20, setForeground(Color.gray, lblSpoiler = jlabel()))),
        withRightMargin(10, jbutton("Next", f next))))))));
      
  setInternalFrameY(internalFrameY2(getInternalFrame(lblInput))+40, showCenteredInternalFrame(desktop, "Analysis", 600, 400,
    centerAndSouth(
      canvas = jcanvas(),
      jcenteredline(jlabel("How is the parse?"),
        btnParseOK = jbutton("OK", f parseOK), btnParseNotOK = jbutton("Not OK", f parseNotOK)))));
  
  next();
  
  awtEvery(lblInput, 5000, r {
    if (auto && !mouseInInternalFrames(canvas, lblInput)) next()
  });
  
  //hideConsole();
}

svoid next {
  S s;
  setText(lblInput, s = random_gac36k());
  setText(lblSpoiler, floatToYesNo(gac36k().get(s)));
  analyze();
}

svoid analyze {
  input = getTextTrim(lblInput);
  triple = ai_tripelize(input);
  parseOK = parseOKMap.get(pair(input, triple));
  buttons();
  Web web = webFromTriple(triple, 0.3, 0.2, 0.7, 0.7);
  if (simplify) web_ai_addSimplifications(web);
  canvas = webToCanvas(web, canvas);
}

svoid parseOK { parseOK(true); }
svoid parseNotOK { parseOK(false); }

svoid parseOK(bool ok) {
  parseOKMap.put(pair(input, triple), parseOK = ok);
  buttons();
  awtLater(lblInput, 1000, f next);
}

svoid buttons {
  setEnabled(btnParseOK, !isTrue(parseOK));
  setEnabled(btnParseNotOK, !isFalse(parseOK));
}

Author comment

Began life as a copy of #1011118

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1011156
Snippet name: Auto GAC 2 [OK, with confirming parses]
Eternal ID of this version: #1011156/17
Text MD5: db5618d8063d5204b979e878e6579140
Transpilation MD5: 40156a875956dcf9d45797bdac10f30e
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-10-19 06:04:10
Source code size: 2385 bytes / 81 lines
Pitched / IR pitched: No / No
Views / Downloads: 452 / 3308
Version history: 16 change(s)
Referenced in: [show references]