Warning: session_start(): open(/var/lib/php/sessions/sess_3q4f367khnfbo9n51b0k4qgav3, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
concept Word {
S text;
long lastUsed;
}
p {
db();
botSleep("Word Holder.");
}
synchronized answer {
if "list words" ret struct(wordsByLastUse());
if "size" ret str(countConcepts(Word));
if "add words *" { ret "OK, " + addWords(javaTokC($1)) + " new"; }
}
static L wordsByLastUse() {
ret collect(sortByFieldDesc(list(Word), "lastUsed"), "text");
}
// return number of new words
static int addWords(L words) {
long lastUsed = now();
int n = 0;
for (S text : words) {
Pair p = uniq2(Word, +text);
if (p.b) ++n;
cset(p.a, +lastUsed);
}
ret n;
}