Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

46
LINES

< > BotCompany Repo | #1027325 // Script Finder

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (12366L/65K).

!7

set flag alwaysSetGlobalIDs.

concept Script > ConceptWithGlobalID {
  S keywords; // comma-separated
  S text;
  S comments;
  //S meta;
  //L uses;
  double score;

  LS keywords() { ret tok_splitAtComma(keywords); }
  
  sS _fieldOrder = "keywords text comments";
}

cmodule ScriptFinder > DynCRUD<Script> {
  SimpleCRUD<Script> makeCRUD() {
    ret setAll(super.makeCRUD(), multiLineFields := litset('text),
      excludeFieldsFromEditing := litset('globalID));
  }

  start {
    dm_registerAs_direct philosophyBot_scriptFinder();
  }

  afterVisualize {
    addComponent_inFront(crud.buttons, jbutton("Extract keywords", rThread {
      extractKeywords(selected());
    }));
  }

  void extractKeywords(Script s) {
    if (s == null) ret;
    cset(s, keywords := joinWithComma(wordsWithoutWeakWords(s.text)));
  }
  
  // API

  L<Script> getScriptsForKeywords(Cl<S> keywords) {
    Set<S> keywordSet = asCISet(keywords);
    ret sortedByScoreFunction_withoutZero(list(),
      s -> l(setIntersection(keywordSet, asCISet(s.keywords()))));
  }
}

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: 251 / 886
Version history: 13 change(s)
Referenced in: [show references]