From patchwork Wed Sep 28 09:27:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lars-Dominik Braun X-Patchwork-Id: 43012 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 32B4827BBEA; Wed, 28 Sep 2022 13:00:25 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D933E27BBE9 for ; Wed, 28 Sep 2022 13:00:24 +0100 (BST) Received: from localhost ([::1]:54168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odVjj-0004Ja-PH for patchwork@mira.cbaines.net; Wed, 28 Sep 2022 08:00:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odTMK-0001PA-7e for guix-patches@gnu.org; Wed, 28 Sep 2022 05:28:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:32829) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1odTMI-0001uA-RI; Wed, 28 Sep 2022 05:28:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1odTMI-0005D6-HS; Wed, 28 Sep 2022 05:28:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58136] [PATCH] ui: Improve sort order when searching package names. Resent-From: Lars-Dominik Braun Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, guix-patches@gnu.org Resent-Date: Wed, 28 Sep 2022 09:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58136 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58136@debbugs.gnu.org Cc: ludo@gnu.org X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: ludo@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.166435727620014 (code B ref -1); Wed, 28 Sep 2022 09:28:02 +0000 Received: (at submit) by debbugs.gnu.org; 28 Sep 2022 09:27:56 +0000 Received: from localhost ([127.0.0.1]:60140 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1odTMA-0005Cj-PX for submit@debbugs.gnu.org; Wed, 28 Sep 2022 05:27:55 -0400 Received: from lists.gnu.org ([209.51.188.17]:45830) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1odTM6-0005CV-VI for submit@debbugs.gnu.org; Wed, 28 Sep 2022 05:27:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odTM6-0000xv-1s for guix-patches@gnu.org; Wed, 28 Sep 2022 05:27:50 -0400 Received: from mout-p-101.mailbox.org ([80.241.56.151]:58070) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1odTM1-0001qc-TH for guix-patches@gnu.org; Wed, 28 Sep 2022 05:27:49 -0400 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4McrkM1kYDz9sm7 for ; Wed, 28 Sep 2022 11:27:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6xq.net; s=MBO0001; t=1664357259; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tMDOUhTonqWUQcCDPMYxDx63BpgJ3CHa5CelZbcPYDg=; b=sCR+nBduy+cBdvsiRtWB4HyQnW/VA13h2ekgU2fDPxjwgLvslCLUWp+xb0URrTmBbG7tUI /Czyu5dcK0YgYN3X2vPJL3fVGltW1gXFPC22modthOgVK2LDYxCBwCPEOQEafOVT+Q3fwi wzTrGE3cLKtxsi8PxDwpVxd+/xYWsaMMyooS8LM4K+uEsJHzSfJyjKQHnQrltJNSE6zCcS qmMlPXWZ3QdhKNm8+MnRlyCog1ZxUkaxUPELbyWXM6Dz5nWVZd8xaoM0eh4SUc9k/nVqo1 J1eMkEw5zokOL2yspE9WcZYUPXmk+AEjZp3xNS30ZqEoqkHGkSPUAysWWQqVjg== Date: Wed, 28 Sep 2022 11:27:37 +0200 From: Lars-Dominik Braun Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Rspamd-Queue-Id: 4McrkM1kYDz9sm7 Received-SPF: pass client-ip=80.241.56.151; envelope-from=lars@6xq.net; helo=mout-p-101.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi, we provide a `guix serach`-based package search to our users and noticed that searching for “ggplot2” yields the package r-ggplot2 on position 11 only – when it should be the first. Looking at other potential search terms (haven, shiny, ape, renv, here, ini, setuptools) reveals similar issues. I propose we also score the unprefixed package name, so SCORE can award bonus points for a full string match. I don’t like that we have to maintain a list of common prefixes for this and that package names are scored twice now, but I can’t think of a better solution right now. Cheers, Lars * guix/ui.scm (%package-metrics): Increase score for PACKAGE-NAME and add score for unprefixed package name. --- guix/ui.scm | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/guix/ui.scm b/guix/ui.scm index dad2b853ac..55b596ed35 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -1655,7 +1655,38 @@ (define (regexp->score regexp) (define %package-metrics ;; Metrics used to compute the "relevance score" of a package against a set ;; of regexps. - `((,package-name . 4) + `((,package-name . 8) + + ;; For packages with a language prefix (namespaces), also compare the + ;; unprefixed name, so searching for “ggplot2” yields + ;; r-ggplot2 as first result instead of other, higher-ranked packages, + ;; which contain “ggplot2” in their description alot. + (,(lambda (package) + (let ((namespaces (list "cl-" + "ecl-" + "emacs-" + "ghc-" + "go-" + "guile-" + "java-" + "julia-" + "node-" + "ocaml-" + "perl-" + "python-" + "r-" + "ruby-" + "rust-" + "sbcl-" + "texlive-")) + (name (package-name package))) + (fold (lambda (prefix accum) + (if (string-prefix? prefix name) + (cons (substring name (string-length prefix)) accum) + accum)) + '() + namespaces))) + . 4) ;; Match against uncommon outputs. (,(lambda (package)