Warning: session_start(): open(/var/lib/php/sessions/sess_pvglhkplt45cmiik5log627a0k, 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 Definition {
S word, definition;
}
module Definitions > DynCRUD {
*() { super(Definition); }
afterVisualize {
replaceComponent(crud.tableSearcher.tfInput, func(JComponent c) -> JComponent {
centerAndEastWithMargin(c, jbutton("Define...", rThread {
define(searchTerm())
}))
});
onEnter(crud.tableSearcher.tfInput, rThread { define(searchTerm()) });
}
void define(fS term) enter {
final JTextField tfWord = jtextfield(or2(term, dm_topInput())), tfDefinition = jtextfield();
showFormTitled("Add Definition",
"Word/Phrase:", tfWord,
"Definition:", tfDefinition,
rThread {
S word = gtt(tfWord), definition = gtt(tfDefinition);
uniq_sync(Definition, +word, +definition);
});
focus(nempty(term) ? tfDefinition : tfWord);
}
enhanceFrame {
internalFrameTitleMenuItem(f, "Import Text...", r {
inputMultiLineText("Definitions (Format: a - b)", "Ice cream - something to eat", voidfunc(S s) {
importText(s)
});
});
}
// API
LS getDefinitions(S word) {
ret collect('definition, conceptsWhereIC(Definition, +word));
}
Map getDefinitionsMap() {
ret main. ciMultiMapFromKeyAndValueField(list(Definition), 'word, 'definition).data;
}
void importText(S text) {
for (S s : tlft(text)) {
LS l = tok_splitAtFirstSpacedDash(s);
if (l(l) == 5)
uniq_sync(Definition, word := l.get(1), definition := l.get(3));
}
}
}