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).

1  
!752
2  
3  
// set these in client
4  
static S dbName = "Boolean Flag DB.";
5  
static L<S> interpretations = splitAtSpace("ShowWindow HideWindow IsShowing Praise Hello NotForMe Unclear");
6  
7  
static RemoteDB db;
8  
static L<RC> lines;
9  
static JTable table;
10  
11  
p-substance {
12  
  fullRefresh();
13  
  L<Component> interpretButtons = map(func(final S cname) {
14  
    jbutton(cname, r { interpret(cname) })
15  
  }, interpretations);
16  
  interpretButtons.add(0, jbutton("Delete", "delete"));
17  
  tableDependButtons(table, interpretButtons);
18  
  addToWindow(table, jMinHeight(50, new JScrollPane(jCenteredLine(
19  
    concatLists(
20  
      ll((Component)
21  
        jbutton("Refresh", "fullRefresh")),
22  
      interpretButtons)))));
23  
}
24  
25  
svoid fullRefresh {
26  
  if (db != null) db.close();
27  
  db = new RemoteDB(dbName);
28  
  //db.db.loud = true;
29  
  refresh();
30  
}
31  
32  
svoid refresh {
33  
  lines = db.xlist("Line");
34  
  table = showTable(table, sortedByFieldIgnoreCase("Input", map(func(RC line) {
35  
    RC intp = db.xgetref(line, "interpretation");
36  
    RC guess = db.xgetref(line, "guess");
37  
    RC guessedAs = guess == null ? null : db.xgetref(guess, "guessedAs");
38  
    ret litorderedmap("Input", db.xS(line, "text"),
39  
      "Interpretation", intp == null ? "uninterpreted" : db.xclass(intp),
40  
      "Guess", guessedAs == null ? "" : db.xS(guessedAs, "text"));
41  
  }, lines)));
42  
}
43  
44  
static void interpret(S cname) {
45  
  L line = getSelectedLine(table);
46  
  if (line == null) ret;
47  
  S text = (S) line.get(0);
48  
  print("Interpreting " + quote(text) + " as " + cname);
49  
  RC ref = (RC) rpc(db.db, "xfindLine", text);
50  
  RC intp = db.uniq(cname);
51  
  db.xset(ref, "interpretation", intp);
52  
  print("Done!");
53  
  refresh();
54  
}
55  
56  
svoid delete {
57  
  L line = getSelectedLine(table);
58  
  if (line == null) ret;
59  
  S text = (S) line.get(0);
60  
  print("Deleting line " + quote(text));
61  
  RC ref = (RC) rpc(db.db, "xfindLine", text);
62  
  db.xdelete(ref);
63  
  print("Done!");
64  
  refresh();
65  
}

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: 705 / 1376
Version history: 2 change(s)
Referenced in: [show references]