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

65
LINES

< > BotCompany Repo | #1004926 // Admin For Text AI

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

Uses 3874K of libraries. Click here for Pure Java version (8312L/57K/198K).

!752

// set these in client
static S dbName = "Boolean Flag DB.";
static L<S> interpretations = splitAtSpace("ShowWindow HideWindow IsShowing Praise Hello NotForMe Unclear");

static RemoteDB db;
static L<RC> lines;
static JTable table;

p-substance {
  fullRefresh();
  L<Component> interpretButtons = map(func(final S cname) {
    jbutton(cname, r { interpret(cname) })
  }, interpretations);
  interpretButtons.add(0, jbutton("Delete", "delete"));
  tableDependButtons(table, interpretButtons);
  addToWindow(table, jMinHeight(50, new JScrollPane(jCenteredLine(
    concatLists(
      ll((Component)
        jbutton("Refresh", "fullRefresh")),
      interpretButtons)))));
}

svoid fullRefresh {
  if (db != null) db.close();
  db = new RemoteDB(dbName);
  //db.db.loud = true;
  refresh();
}

svoid refresh {
  lines = db.xlist("Line");
  table = showTable(table, sortedByFieldIgnoreCase("Input", map(func(RC line) {
    RC intp = db.xgetref(line, "interpretation");
    RC guess = db.xgetref(line, "guess");
    RC guessedAs = guess == null ? null : db.xgetref(guess, "guessedAs");
    ret litorderedmap("Input", db.xS(line, "text"),
      "Interpretation", intp == null ? "uninterpreted" : db.xclass(intp),
      "Guess", guessedAs == null ? "" : db.xS(guessedAs, "text"));
  }, lines)));
}

static void interpret(S cname) {
  L line = getSelectedLine(table);
  if (line == null) ret;
  S text = (S) line.get(0);
  print("Interpreting " + quote(text) + " as " + cname);
  RC ref = (RC) rpc(db.db, "xfindLine", text);
  RC intp = db.uniq(cname);
  db.xset(ref, "interpretation", intp);
  print("Done!");
  refresh();
}

svoid delete {
  L line = getSelectedLine(table);
  if (line == null) ret;
  S text = (S) line.get(0);
  print("Deleting line " + quote(text));
  RC ref = (RC) rpc(db.db, "xfindLine", text);
  db.xdelete(ref);
  print("Done!");
  refresh();
}

Author comment

Began life as a copy of #1004922

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1004926
Snippet name: Admin For Text AI
Eternal ID of this version: #1004926/3
Text MD5: e32604c91b224829e6290a7f707f3b8f
Transpilation MD5: d1b3e70dcb7868e52d4e0c690c1c957c
Author: stefan
Category: javax / a.i.
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-15 14:43:05
Source code size: 1932 bytes / 65 lines
Pitched / IR pitched: No / No
Views / Downloads: 704 / 1374
Version history: 2 change(s)
Referenced in: [show references]