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

15
LINES

< > BotCompany Repo | #1030973 // scoredSearch_scoreWeighted - where each search word has a weight

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2760L/16K).

// Search for some words in some texts and return a total score
static double scoredSearch_scoreWeighted(Iterable<S> l, LPair<S, Double> words) {
  double score = 0;
  if (l != null) for (S s : l)
    score += scoredSearch_scoreWeighted(s, words);
  ret score;
}

static double scoredSearch_scoreWeighted(S s, LPair<S, Double> words) {
  int score = 0;
  if (nempty(s))
    for (S word, double weight : unpair words)
      score += scoredSearch_score_single(s, word)*weight;
  ret score;
}

Author comment

Began life as a copy of #1011593

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030973
Snippet name: scoredSearch_scoreWeighted - where each search word has a weight
Eternal ID of this version: #1030973/1
Text MD5: c37063cda9e2adcdb8097be4a9314978
Transpilation MD5: 275e96b4fb055390dedc304d20d8d53a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-17 14:03:21
Source code size: 503 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 150 / 225
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1030974 - scoredSearch_scoreWeighted2 - where each field has a weight