summaryrefslogtreecommitdiff
path: root/guix/scripts/package.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-09-13 15:07:17 +0200
committerLudovic Courtès <ludo@gnu.org>2017-09-16 17:47:45 +0200
commitc7ae219e399804a8eb33f176e532a79b389ee1f1 (patch)
tree0ad5ed041fcc2c29610ce55103beaa65f5adf1a0 /guix/scripts/package.scm
parentdab666cd8d91bf2c4aacc920e3ea2ec01221123f (diff)
downloadgnu-guix-c7ae219e399804a8eb33f176e532a79b389ee1f1.tar
gnu-guix-c7ae219e399804a8eb33f176e532a79b389ee1f1.tar.gz
ui: Generalize relevance computation.
* guix/ui.scm (relevance, package-relevance): New procedures. (%package-metrics): New variable. * guix/scripts/package.scm (find-packages-by-description)[score] [package-score]: Remove. Use 'package-relevance' instead.
Diffstat (limited to 'guix/scripts/package.scm')
-rw-r--r--guix/scripts/package.scm21
1 files changed, 1 insertions, 20 deletions
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 9ec6950c4b..4adc705220 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -246,27 +246,8 @@ specified in MANIFEST, a manifest object."
"Return two values: the list of packages whose name, synopsis, or
description matches at least one of REGEXPS sorted by relevance, and the list
of relevance scores."
- (define (score str)
- (let ((counts (filter-map (lambda (regexp)
- (match (regexp-exec regexp str)
- (#f #f)
- (m (match:count m))))
- regexps)))
- ;; Compute a score that's proportional to the number of regexps matched
- ;; and to the number of matches for each regexp.
- (* (length counts) (reduce + 0 counts))))
-
- (define (package-score package)
- (+ (* 3 (score (package-name package)))
- (* 2 (match (package-synopsis package)
- ((? string? str) (score (P_ str)))
- (#f 0)))
- (match (package-description package)
- ((? string? str) (score (P_ str)))
- (#f 0))))
-
(let ((matches (fold-packages (lambda (package result)
- (match (package-score package)
+ (match (package-relevance package regexps)
((? zero?)
result)
(score