diff mbox series

[bug#58136] ui: Improve sort order when searching package names.

Message ID 86wn9na82p.fsf@gmail.com
State New
Headers show
Series [bug#58136] ui: Improve sort order when searching package names. | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Simon Tournier Sept. 28, 2022, 2:26 p.m. UTC
Hi Lars,

On Wed, 28 Sep 2022 at 11:27, Lars-Dominik Braun <lars@6xq.net> wrote:

> 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.

In addition to your proposal which LGTM, maybe we could also use the
’upstream-name’ properties.  Most of the time, the Guix name matches the
upstream name, but sometimes not.  Although, it would not fix the issue
for ggplot2 since there is no upstream-name for this package. :-)

Well, I propose something like see below (based on your patch):

 1. keep the weight as 4
 2. set the “namespace” weight to 1 (or 2 if you prefer)

    Otherwise, for example, generic name as CSV could artificially bump
    the relevance and hide relevant packages.  For instance, compare

       guix search csv

 3. use upstream-name if provided

WDYT?


--8<---------------cut here---------------start------------->8---
--8<---------------cut here---------------end--------------->8---


Cheers,
simon

Comments

M Sept. 28, 2022, 8:23 p.m. UTC | #1
> +    ;; For packages with a language prefix (namespaces), also compare the

You missed "minetest-"

On 28-09-2022 16:26, zimoun wrote:
>   3. use upstream-name if provided
> 
> WDYT?

For the Minetest mods (which have upstream-names like "Jeija/mesecons"), 
I don't think think the upstream-name is useful as-is

Greetings,
Maxime.
M Sept. 28, 2022, 8:45 p.m. UTC | #2
On 28-09-2022 22:23, Maxime Devos wrote:
> You missed "minetest-"

Also, "lua-".
Simon Tournier Sept. 28, 2022, 9:40 p.m. UTC | #3
Hi,

On mer., 28 sept. 2022 at 22:23, Maxime Devos <maximedevos@telenet.be> wrote:

> On 28-09-2022 16:26, zimoun wrote:
>>   3. use upstream-name if provided
>
> For the Minetest mods (which have upstream-names like "Jeija/mesecons"), 
> I don't think think the upstream-name is useful as-is

Using the change I am proposing, just knowing ’jeija’ returns a match:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix search jeija
name: minetest-mesecons
version: 1.2.1-63.27c3c51
outputs:
+ out: everything else
systems: x86_64-linux
dependencies: 
location: gnu/packages/minetest.scm:367:4
homepage: https://mesecons.net
license: LGPL 3, CC-BY-SA 3.0
synopsis: Digital circuitry for Minetest, including wires, buttons and lights  
description: Mesecons is a mod for Minetest implementing various items
+ related to digital circuitry, such as wires, buttons, lights and programmable
+ controllers.  Among other things, there are also pistons, solar panels,
+ pressure plates and note blocks.
+ 
+ Mesecons has a similar goal to Redstone in Minecraft, but works in its own
+ way, with different rules and mechanics.
relevance: 4
--8<---------------cut here---------------end--------------->8---

which is better than nothing.

Well, upstream-name is not so much useful as-is but it can help for some
cases.


Cheers,
simon
M Sept. 28, 2022, 9:43 p.m. UTC | #4
On 28-09-2022 23:40, zimoun wrote:
> Using the change I am proposing, just knowing ’jeija’ returns a match:
> 
> --8<---------------cut here---------------start------------->8---
> $ ./pre-inst-env guix search jeija
> name: minetest-mesecons
 > [...]

Right, didn't think of that.

Greetings,
Maxime.
Ludovic Courtès Oct. 1, 2022, 9:42 p.m. UTC | #5
Hi,

zimoun <zimon.toutoune@gmail.com> skribis:

> Well, I propose something like see below (based on your patch):
>
>  1. keep the weight as 4
>  2. set the “namespace” weight to 1 (or 2 if you prefer)
>
>     Otherwise, for example, generic name as CSV could artificially bump
>     the relevance and hide relevant packages.  For instance, compare
>
>        guix search csv
>
>  3. use upstream-name if provided

Maybe something like:

  (define %package-metrics
    `((,package-name . 4)
      (,package-upstream-name* . 4)  ;or a lower weight, dunno
      …))

where:

  (define (package-upstream-name* package)
    (or (assoc-ref (package-properties package) 'upstream-name)
        (package-name-sans-namespace package)))  ;strip "r-", "emacs-", etc.

WDYT?

(Perhaps ‘package-upstream-name’ could be taught about these implicit
name conversions done for R, Python, Emacs, etc.?)

Ludo’.
Simon Tournier Oct. 2, 2022, 8:26 a.m. UTC | #6
Hi,

On Sat, 01 Oct 2022 at 23:42, Ludovic Courtès <ludo@gnu.org> wrote:

>   (define (package-upstream-name* package)
>     (or (assoc-ref (package-properties package) 'upstream-name)
>         (package-name-sans-namespace package)))  ;strip "r-", "emacs-", etc.

I think it is better to rely on ’package-upstream-name’ and hides the
plumbing.  It helps when something needs to be “refactored“, IMHO.


> (Perhaps ‘package-upstream-name’ could be taught about these implicit
> name conversions done for R, Python, Emacs, etc.?)

Maybe, but it requires to scrutinize importer per importer since
upstream name is mainly used by these, IIUC.


Cheers,
simon
diff mbox series

Patch

diff --git a/guix/ui.scm b/guix/ui.scm
index 55b596ed35..14f296a546 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -1655,7 +1655,7 @@  (define (regexp->score regexp)
 (define %package-metrics
   ;; Metrics used to compute the "relevance score" of a package against a set
   ;; of regexps.
-  `((,package-name . 8)
+  `((,package-name . 4)
 
     ;; For packages with a language prefix (namespaces), also compare the
     ;; unprefixed name, so searching for “ggplot2” yields
@@ -1684,9 +1684,9 @@  (define %package-metrics
                   (if (string-prefix? prefix name)
                       (cons (substring name (string-length prefix)) accum)
                       accum))
-                '()
+                (list (package-upstream-name package))
                 namespaces)))
-       . 4)
+     . 1)
 
     ;; Match against uncommon outputs.
     (,(lambda (package)