Uses 911K of libraries. Click here for Pure Java version (12366L/65K).
1 | !7 |
2 | |
3 | set flag alwaysSetGlobalIDs. |
4 | |
5 | concept Script > ConceptWithGlobalID { |
6 | S keywords; // comma-separated |
7 | S text; |
8 | S comments; |
9 | //S meta; |
10 | //L uses; |
11 | double score; |
12 | |
13 | LS keywords() { ret tok_splitAtComma(keywords); } |
14 | |
15 | sS _fieldOrder = "keywords text comments"; |
16 | } |
17 | |
18 | cmodule ScriptFinder > DynCRUD<Script> { |
19 | SimpleCRUD<Script> makeCRUD() { |
20 | ret setAll(super.makeCRUD(), multiLineFields := litset('text), |
21 | excludeFieldsFromEditing := litset('globalID)); |
22 | } |
23 | |
24 | start { |
25 | dm_registerAs_direct philosophyBot_scriptFinder(); |
26 | } |
27 | |
28 | afterVisualize { |
29 | addComponent_inFront(crud.buttons, jbutton("Extract keywords", rThread { |
30 | extractKeywords(selected()); |
31 | })); |
32 | } |
33 | |
34 | void extractKeywords(Script s) { |
35 | if (s == null) ret; |
36 | cset(s, keywords := joinWithComma(wordsWithoutWeakWords(s.text))); |
37 | } |
38 | |
39 | // API |
40 | |
41 | L<Script> getScriptsForKeywords(Cl<S> keywords) { |
42 | Set<S> keywordSet = asCISet(keywords); |
43 | ret sortedByScoreFunction_withoutZero(list(), |
44 | s -> l(setIntersection(keywordSet, asCISet(s.keywords())))); |
45 | } |
46 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027325 |
Snippet name: | Script Finder |
Eternal ID of this version: | #1027325/14 |
Text MD5: | 17d9c8b6904a6f3f073f8f759c611546 |
Transpilation MD5: | c3e78dd494d0e88c26437306cb610cbc |
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-06 13:33:53 |
Source code size: | 1071 bytes / 46 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 253 / 888 |
Version history: | 13 change(s) |
Referenced in: | [show references] |