From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id YHb5NIcjTWP+8QAAbAwnHQ (envelope-from ) for ; Mon, 17 Oct 2022 11:42:31 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id MEIDNYcjTWPYDQAA9RJhRA (envelope-from ) for ; Mon, 17 Oct 2022 11:42:31 +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 8DA748D98 for ; Mon, 17 Oct 2022 11:42:31 +0200 (CEST) Received: from localhost ([::1]:54696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okMdi-0006bG-KD for larch@yhetil.org; Mon, 17 Oct 2022 05:42:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okMSd-0005iB-W8 for guix-patches@gnu.org; Mon, 17 Oct 2022 05:31:09 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48284) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1okMSd-0003jN-OX for guix-patches@gnu.org; Mon, 17 Oct 2022 05:31:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1okMSd-0008D0-Jj for guix-patches@gnu.org; Mon, 17 Oct 2022 05:31:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58136] [PATCH] ui: Improve sort order when searching package names. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 17 Oct 2022 09:31:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58136 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Lars-Dominik Braun Cc: 58136@debbugs.gnu.org Received: via spool by 58136-submit@debbugs.gnu.org id=B58136.166599906231514 (code B ref 58136); Mon, 17 Oct 2022 09:31:03 +0000 Received: (at 58136) by debbugs.gnu.org; 17 Oct 2022 09:31:02 +0000 Received: from localhost ([127.0.0.1]:47353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1okMSb-0008C5-P5 for submit@debbugs.gnu.org; Mon, 17 Oct 2022 05:31:02 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:37669) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1okMSZ-0008BT-TH for 58136@debbugs.gnu.org; Mon, 17 Oct 2022 05:31:00 -0400 Received: by mail-wr1-f53.google.com with SMTP id bv10so17542516wrb.4 for <58136@debbugs.gnu.org>; Mon, 17 Oct 2022 02:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=VfVCgzLqrQhC1RNY/hKcagmFjrRM9+sW94Z0a3X+t8c=; b=iawhRgG+XA4JA1ATykC2j670ztAUV1khHpqbXKeMJkJd7EEcfKVWn9EbMKwZLBk5MG cHaGx+T1NEIWBfFE2mEy24NhOgQzNwjOkbM8BUTsVKG9b4mPu8OYIhWhSBqbEbuLXckH Vk9v8jb7GHMRweCb4lrHEeMPpIfbtcGLx7J0LR8JNVVX7MwPp/qc4bqT474P+zqvqvBS 3kCsaclLGrc/bgILL9kyuHVrHTnT6EzccLQ76bmrMNc2iW9LC9IA88/W8ZNx6rVB5yh5 rwt4Kve1XJ9HJEOTRMBPHi++AYIRf7xPOQn7kG8W5z2a+EKXchwlh08ShEtzdGrcYzA2 dvWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VfVCgzLqrQhC1RNY/hKcagmFjrRM9+sW94Z0a3X+t8c=; b=lBBS4hBUPo3HdUiQ/adHjOWj+UynAwA2DJ6kcBDK+8txXoox7zlE8GlRFS3DgqnuRw kvgLsWrDxhkTqeeuNS6OOZvgtkGcsvR11pIfVXDxIdsA3HQ0Jc8q2Pe48axyEwqcSrDe lbWhTad3gLARb5vIOpEA61ohuxY+uFIwDqKdDKvErq+MU8R54/AY8izF09zQ4lwi3tkO TokdLuui9ohTRCVOseGv8UwobfFCXnIk8cyyBJi0a1NSSmL3S9F6eyMCZ3NszNwNQ7cQ N6HzEox+tr4sGOMbYEQwAg3I+wvu6WFxHquy6ItpdJPA4gQ5fNHLI68MVIox2iKZJdxH eVDA== X-Gm-Message-State: ACrzQf0LqibEg8Owd2FIKx/7+NErLhS3tVACxrZ3FSSHkzcVc9sKMGuD AwaKVSNVy0LLH6ep9pjTjb2LreN3/5I= X-Google-Smtp-Source: AMsMyM6qLZm7IBZekR6zuzYQ61NJfFZ5mGjCrZBhoq7S1qxAKSpvjpDgYZRv8WicNOFgBD2SfTBdcg== X-Received: by 2002:adf:ec83:0:b0:22e:51e2:7fc7 with SMTP id z3-20020adfec83000000b0022e51e27fc7mr5449865wrn.229.1665999053790; Mon, 17 Oct 2022 02:30:53 -0700 (PDT) Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id y3-20020a7bcd83000000b003b492753826sm9461298wmj.43.2022.10.17.02.30.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 02:30:53 -0700 (PDT) From: zimoun In-Reply-To: <8735bmj3jf.fsf_-_@gnu.org> References: <86wn9na82p.fsf@gmail.com> <8735bmj3jf.fsf_-_@gnu.org> Date: Mon, 17 Oct 2022 10:19:48 +0200 Message-ID: <877d0yoo9n.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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=1665999751; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=VfVCgzLqrQhC1RNY/hKcagmFjrRM9+sW94Z0a3X+t8c=; b=D4cXhkfAmft6J3YgKSPXR10qjlrW4yILJzXBpD2TCooevShCJ56+A+oVwOe3b6hsr4tgSe Rwb3NPJV9aJUy3yrs4eOdk80QIscvXhnMOCxp59m5+zwEPMSnOr9jpgAvQe1sBZJjmMQ+Q iRslYAYynRkwM22nz/jJggvQ8mAu3bAGEAdxZSNNhDydrX6rvbBQlBFxBZRDrXJNArhvKK 9noVlWD3XSy6OKH2CxGbrarFoL/mSXXMXPsHbvO05zdFjzSc4rC4MWVCQu66jHoMcYw1/R 5TpqKezKv6KdUxzDrcZpbzQPIW+sXr5k1+mgcCB/zfQbgMPh0YVdg3R4JCSY4w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665999751; a=rsa-sha256; cv=none; b=L8HAlBaClgmB/3hpSRhcwRPl7GZI7Co9Gs7Eg7+7ajKpZhzOydJEQbqmIt8e3ltFBQh/+1 QGSvcZ7pLCjY5hcRkDKdFG93CnJC+CsyW/uFcQCU3K3DbghqsWYz+hvRV2VkTHC0NHeGHC fAp/g04Ms/htUOfbQ6MI4JfLbIFnIOUVEN4Tk+2PXVeGw316yRZP1eLFFfqEPSCITFsxtg MLzVBVZE7EA+Ri/cBLa6tqDfa0KXxzB9vRexB22weEGblVAn2tckLA6lzAxrcyVfyZ+gjl EgQUE4CuHUJesRLHreJlemi9/q5R230p1KwNnLvnSVoe4DyfK3soZAWCKbjuyg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=iawhRgG+; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (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: 6.08 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=iawhRgG+; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (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: 8DA748D98 X-Spam-Score: 6.08 X-Migadu-Scanner: scn1.migadu.com X-TUID: p6x54kvvvE1w Hi Lars, Ludo, In short, I miss why the initial patch with a minor tweak is not enough for covering the corner cases. :-) On lun., 17 oct. 2022 at 09:46, Ludovic Court=C3=A8s wrote: >> +++ b/guix/ui.scm >> @@ -1623,10 +1623,23 @@ (define (relevance obj regexps metrics) >> (define (score regexp str) >> (fold-matches regexp str 0 >> (lambda (m score) >> - (+ score >> - (if (string=3D? (match:substring m) str) >> - 5 ;exact match >> - 1))))) >> + (let* ((start (- (match:start m) 1)) >> + (end (match:end m)) >> + (left (if (>=3D start 0) (string-ref str sta= rt) #f)) >> + (right (if (< end (string-length str)) (stri= ng-ref str end) #f)) >> + (delimiter-classes '(Cc Cf Pd Pe Pf Pi Po Ps= Sk Zs Zl Zp)) >> + (delim-left (or (member (and=3D> left char-g= eneral-category) delimiter-classes) (eq? left #f))) >> + (delim-right (or (member (and=3D> right char= -general-category) delimiter-classes) (eq? right #f)))) >> + (max score >> + (cond >> + ;; regexp is a full match for str. >> + ((and (eq? left #f) (eq? right #f)) 4) >> + ;; regexp matches a single word in str. >> + ((and delim-left delim-right) 3) >> + ;; regexp matches the beginning or end of a w= ord in str. >> + ((or delim-left delim-right) 2) >> + ;; Everything else. >> + (#t 1))))))) > > The intent is to have all regexps behave as if the user passed \, > is that right? Would be nice to have a comment clarifying that above > and perhaps making it a separate change? All this appears to me overcomplicated. Personally, I have to read it many times to get the logic; while the initial patch was much clearer, IMHO. Other said, I am not convinced the complexity is worth the corner case. The initial patch with the minor tweak I am proposing (maybe using package-upstream-name*) appears to me enough for covering the corner cases initially reported (as ggplot2). >> @@ -1635,10 +1648,11 @@ (define (regexp->score regexp) >> ((field . weight) >> (match (field obj) >> (#f relevance) >> + ('() relevance) >> ((? string? str) >> - (+ relevance (* (score-regexp str) weight))) >> + (max relevance (* (score-regexp str) weight))) >> ((lst ...) >> - (+ relevance (* weight (apply + (map score-regexp l= st))))))))) >> + (max relevance (* weight (apply max (map score-rege= xp lst))))))))) > > Intuitively I would expect scores to add up, otherwise we=E2=80=99re kinda > losing information; so I would not make this change. WDYT? I agree with Ludo that =E2=80=99max=E2=80=99 is counterintuitive. Well, could we list some examples (keyword and expectation)? Because the initial patch with a minor tweak LGTM and covers ggplot2, csv, and some others. Cheers, simon