!7 static JTextField tf; static SingleComponentPanel scp; static Canvas canvas; static Q q; // action queue static volatile bool boss; // boss mode (after pressing Escape) static L aiConcepts; !include #1007377 // traits for CirclesAndLines p-substance-thread { aiEnhancements(); aiConcepts = loadAIConcepts(); //final S word = getString(random(aiConcepts), /*"name"*/"globalID"); final S word = "yorqibybrndchtxr"; swing { q = new Q(true); JFrame frame = showFrame(northAndCenter(tf = setTextFieldFontSize(jCenteredTextField(word), 20), scp = new SingleComponentPanel)); registerEscape(frame, r { boss = true; tf.setText(""); scp.noComponent(); }); centerFrame(frameInnerSize(frame, 600, 600)); addMenu(frame, "Menu!", "Show AI Concepts", r { startOrActivate(#1006463) }, "Clear Cache", r { aiConceptsMap_clearCache() }); onEnterAndNow(tf, r { boss = false; awt { tf.selectAll(); } final S text = getTextTrim(tf); q.add(r { if (boss) ret; long time = sysNow(); loading { final CirclesAndLines cal = render(text); if (boss) ret; awt { scp.setComponent(centerAndSouth( /*jscroll_centered*/(cal.makeCanvas()), setFont(sansSerifBold(20), jcenteredlabel(text)))); } } sleepUntilSys(time+1000); // min display time }); }); //hideConsole(); } } static CirclesAndLines render(S text) { pcall { text = englishToConceptLanguage(text); } print("Text: " + text); if (possibleGlobalID(text)) { AIConcept c = findWhere(aiConcepts, globalID := text); if (c != null) { print("Have concept (" + c.globalID + " - " + c.name + ")"); ret renderConcept(c); } } new CirclesAndLines cal; for (S s : splitAtPlus(text)) cal.circle_autoVis(s, 0.5, 0.5); autoPositionCircles(cal); ret cal; } static CirclesAndLines renderConcept(AIConcept c) { new CirclesAndLines cal; conceptCircle(cal, c, true); autoPositionCircles(cal); ret cal; } static Circle conceptCircle(CirclesAndLines cal, S conceptID, bool withRelations) { AIConcept c = aiConceptsMap_cached().get(conceptID); if (c == null) ret cal.circle(conceptID + " [?]", 0.5, 0.5); ret conceptCircle(cal, c, withRelations); } static Circle conceptCircle(CirclesAndLines cal, AIConcept c, bool withRelations) { BufferedImage img = getConceptImage(c); Circle cc; print("conceptCircle " + c.globalID + " img: " + (img != null)); if (img != null) cc = cal.circle(img, 0.5, 0.5, c.name); else cc = cal.circle_autoVis(c.name, 0.5, 0.5); cc.addTrait(c.globalID); if (withRelations) findRelations(cal, cc, c); ret cc; } svoid findRelations(CirclesAndLines cal, Circle cc, AIConcept c) { S id = c.globalID; for (S s : trueStatements_cached()) { Lisp l = clParse(s); //print("Statement found: " + l); if (l.size() == 2 && eq(l.getString(0), id)) { //print("Match: " + l); S label = makeLabel(l.head); Circle dd = conceptCircle(cal, l.getString(1), false); cal.arrow(cc, label, dd); } } } sS makeLabel(S id) { SS map = litmap( "gqlkqsxygqmmptoi", "SHORT FOR", "yppdjirdezcvlhhg", "SYNONYM"); try answer map.get(id); S name = conceptToName(id); new Matches m; if (flexMatch("X * Y", name, m)) ret toUpper($1); ret toUpper(id); }