From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id WP32K1E3NGO8hgAAbAwnHQ (envelope-from ) for ; Wed, 28 Sep 2022 14:00:17 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id sIEqK1E3NGOiJgAAG6o9tA (envelope-from ) for ; Wed, 28 Sep 2022 14:00:17 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 500953E960 for ; Wed, 28 Sep 2022 14:00:17 +0200 (CEST) Received: from localhost ([::1]:54168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odVjb-0004Ja-VL for larch@yhetil.org; Wed, 28 Sep 2022 08:00:16 -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-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664366417; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=tMDOUhTonqWUQcCDPMYxDx63BpgJ3CHa5CelZbcPYDg=; b=J15fRRy+fMInQMblW/yVor0ZRawnDaO5yLTPWqIchhOoi6Evwos0NFoqU/Dhk0nTG/lgS+ RvzPpOtFZdYMfp6rE0roLBxZr0LxnzDxrzO9NU28Sfp4vs9Lu1ewSXY6Y/V4fFpxWp1p7a l1bSrvasmEbrF5V6l0GWLcsm8zN8PwWOwr6fDhFCSpgYsXF4QtLngfVuKmCtlw7q9596Np hEhcHdC3fedIrVhIns1nRO41le3dw6s3+MMkgB+/e64jdFgdIoVbGHce7ifF+EJQNWLJ+R dTeDeYNU3iaRPh/278qQQpotalHVaKf1rud6ckYzyInkM492Tc0Z0Pvgdlahyw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664366417; a=rsa-sha256; cv=none; b=NOXKcuOzvYSqgLDt8i9it89053SwHHHFBmatFELFsTls40yeH8lb+huqwTsbXQzuWw8Lh0 iQBdM7NAQnqOskeFSp4IfIRDwbECCoNHcND41Jhe5MKRNlNL0ZfrnB+Yn9dSgJoBvmgDSn NrlQmru/XIWu75hlHTR76xpl/pqqIQfKAsexICFp930fN0WxoKhCb4z0TzHD4HwkLOfRf0 xgEiwqozoRK6ONqFw+V3vWGZDHXxB1sow2EDIsWtljSbd56T9NfVkiJmyFsHGGAByW7RCQ y0ntpgvvECPUMvOVPhQ5iE7qOcD+Golo5oRFehZzjMFBcU99cHMYwJJh+si6YQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=6xq.net header.s=MBO0001 header.b=sCR+nBdu; dmarc=fail reason="SPF not aligned (relaxed)" header.from=6xq.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 5.75 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=6xq.net header.s=MBO0001 header.b=sCR+nBdu; dmarc=fail reason="SPF not aligned (relaxed)" header.from=6xq.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 500953E960 X-Spam-Score: 5.75 X-Migadu-Scanner: scn1.migadu.com X-TUID: EcyTbWtYBomC 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) -- 2.35.1