Uses 911K of libraries. Click here for Pure Java version (16469L/89K).
1 | !7 |
2 | |
3 | concept Definition { |
4 | S word, definition; |
5 | |
6 | sS _fieldOrder = "word definition"; |
7 | } |
8 | |
9 | cmodule Definitions > DynCRUD<Definition> { |
10 | start { |
11 | dbIndexingCI(Definition, 'word, Definition, 'definition); |
12 | } |
13 | |
14 | afterVisualize { |
15 | replaceComponent(crud.tableSearcher.tfInput, func(JComponent c) -> JComponent { |
16 | centerAndEastWithMargin(c, jbutton("Define...", rThread { |
17 | define(searchTerm()) |
18 | })) |
19 | }); |
20 | onEnter(crud.tableSearcher.tfInput, rThread { define(searchTerm()) }); |
21 | } |
22 | |
23 | void define(fS term) enter { |
24 | final JTextField tfWord = jtextfield(or2(term, dm_topInput())), tfDefinition = jtextfield(); |
25 | showFormTitled("Add Definition", |
26 | "Word/Phrase:", tfWord, |
27 | "Definition:", tfDefinition, |
28 | rThread { |
29 | S word = gtt(tfWord), definition = gtt(tfDefinition); |
30 | uniq_sync(Definition, +word, +definition); |
31 | }); |
32 | focus(nempty(term) ? tfDefinition : tfWord); |
33 | } |
34 | |
35 | enhanceFrame { |
36 | internalFrameTitleMenuItem(f, "Import Text...", r { |
37 | inputMultiLineText("Definitions (Format: a - b)", "Ice cream - something to eat", voidfunc(S s) { |
38 | importText(s) |
39 | }); |
40 | }); |
41 | } |
42 | |
43 | // API |
44 | |
45 | LS getDefinitions(S word) { |
46 | ret collect('definition, conceptsWhereIC(Definition, +word)); |
47 | } |
48 | |
49 | LS getReverseDefinitions(S definition) { |
50 | ret collect('word, conceptsWhereIC(Definition, +definition)); |
51 | } |
52 | |
53 | Map<S, LS> getDefinitionsMap() { |
54 | ret main.<S> ciMultiMapFromKeyAndValueField(list(Definition), 'word, 'definition).data; |
55 | } |
56 | |
57 | void importText(S text) { |
58 | for (S s : tlft(text)) { |
59 | LS l = tok_splitAtFirstSpacedDash(s); |
60 | if (l(l) == 5) |
61 | uniq_sync(Definition, word := l.get(1), definition := l.get(3)); |
62 | } |
63 | } |
64 | |
65 | S exportAsText() { |
66 | ret lines(map(list(Definition), func(Definition d) -> S { |
67 | d.word + " - " + d.definition |
68 | })); |
69 | } |
70 | |
71 | void addDefinition(S word, S definition) { |
72 | uniq_sync(Definition, +word, +definition); |
73 | } |
74 | } |
Began life as a copy of #1019484
download show line numbers debug dex old transpilations
Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1019714 |
Snippet name: | Definitions [Dyn Module] |
Eternal ID of this version: | #1019714/26 |
Text MD5: | 3c06c6289232ca26e2418d55d9ec6f7a |
Transpilation MD5: | 4b7ebf6ab94c9f2559da44abac28da48 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-03-22 21:27:15 |
Source code size: | 2033 bytes / 74 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 391 / 12598 |
Version history: | 25 change(s) |
Referenced in: | [show references] |