From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id kCjFDoNL5GYAWgAA62LTzQ:P1 (envelope-from ) for ; Fri, 13 Sep 2024 14:26:11 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id kCjFDoNL5GYAWgAA62LTzQ (envelope-from ) for ; Fri, 13 Sep 2024 16:26:11 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=MabRbQAQ; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=XmLaYGHT; 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"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1726237571; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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=YjwUwsr9pxU7mCEhFkg98Ymg5vreMKnsBqb+7RbbJI8=; b=JpPASm+V5gzgW5YXeUO5Jg/n1ZunBObimzfvSKcZZbv4cvEYGCS1xbIUMKxhtSDVyUBrkV SRU4R3Kxy8bi1XeixcFRMTIcnzkRDWisVg/PobsJ6OR1hkEqibz2vs25QTQ4ESbEBnIMWQ vtSispsv+vrkYDq2SmM4BQTCSwU0hLNZQ6N929neM+AK/HNp9BORKiK2F7zvQJI0IkpLfF FAD8j2D3sk/fP76KysRtpsfT2BIdKcxUPqsBKMxYpo7yMOAD3lk+3xxNZ9frgL/ZmIsHmh dmPo12BUjBr9gkB48Rfnp64kiTuLfbm01YddYzV8IarwORpLTlnPzUVtsi5RYg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1726237571; a=rsa-sha256; cv=none; b=OgEMMFsal+EzGdehgRL39sTuXeo1u4BqbLe/YPlNhcwNl23Jig3bxFLjE9HFwAe4Yugoig zZNUsYD3tA72z1YxJCOUj9mFMA6cFIvt9VJLmpuubINYaXp65+oHhSwXo+aebkjd0j2r/u 4yWD8N5U2czcCgThqC1UQlyEsA4Y1wlkaeO3ubSdzw8CuJIwcO//E6XmGl3mdGL3/BrJ3A l3sESHM4FCu/GUeyDAv9g+xzkXK4yCVdqo/PIZrMJdxpJDAynI/hZ99LBj44cZXlUdeRaP QiW2Z6uvn+9CBKxo66rMuaP3hcskrMZ87fnw5Ghcogxxrv1GWZdOVOG5uqhvkQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=MabRbQAQ; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=XmLaYGHT; 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"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none) 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 ECA901E1FC for ; Fri, 13 Sep 2024 16:26:10 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sp7FH-0000RG-UN; Fri, 13 Sep 2024 10:25:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sp7FE-0000Lk-9p for guix-patches@gnu.org; Fri, 13 Sep 2024 10:25:56 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sp7FD-0002CU-Or; Fri, 13 Sep 2024 10:25:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:In-Reply-To:References:Subject; bh=YjwUwsr9pxU7mCEhFkg98Ymg5vreMKnsBqb+7RbbJI8=; b=MabRbQAQxIdsS4tPhhvifQ0grxmyBaiEvD6aXVg2AxFVifne7UJK0pt1nbIIzSZe0W09Dx5FbhZW08WV3KRLGAmkDBaQwKhoNOtVOav3VQO2P1yPfHPMdGrifzKjWtSk8rwoaY9PXpUg2WArsUmk2C0C9bM72GmhWvqAibPjCA+6BA5gwVRI1dWpazYC+/iMNbt0n/wB5lXr9uYbLiYlM2lTIO5dUPO3PNMMFUDbpOCJTu5o06ErQ2V0706rPOjdAkd6nwQAWtbe/q1IiQS/cjGteEbCMbvsKUKpUpoUwo+JhnkpNY1Ep9bJqjPmUPh4SHLxktXwKgZmbJ+fOsI9Nw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sp7FK-00020W-Er; Fri, 13 Sep 2024 10:26:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#73220] [PATCH v2] ui: Add partial match relevance scoring. References: In-Reply-To: Resent-From: Simon Tournier Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Fri, 13 Sep 2024 14:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73220 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 73220@debbugs.gnu.org Cc: aurtzy@gmail.com, Simon Tournier , Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 73220-submit@debbugs.gnu.org id=B73220.17262375287598 (code B ref 73220); Fri, 13 Sep 2024 14:26:02 +0000 Received: (at 73220) by debbugs.gnu.org; 13 Sep 2024 14:25:28 +0000 Received: from localhost ([127.0.0.1]:43919 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sp7El-0001yU-UG for submit@debbugs.gnu.org; Fri, 13 Sep 2024 10:25:28 -0400 Received: from mail-wr1-f51.google.com ([209.85.221.51]:54720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sp7Ek-0001y1-43 for 73220@debbugs.gnu.org; Fri, 13 Sep 2024 10:25:26 -0400 Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-374bd059b12so675576f8f.1 for <73220@debbugs.gnu.org>; Fri, 13 Sep 2024 07:25:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726237451; x=1726842251; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YjwUwsr9pxU7mCEhFkg98Ymg5vreMKnsBqb+7RbbJI8=; b=XmLaYGHTb7AzeA874u2nOeZm2DsQN1NAbdyRHa/PNIXctw8LOrR3dz+DQTEggNY6GK bM2x9YAeae6LmDjt/6azQsdMa1HxrnzoRNppoAbrQlhqEoMarxzYnIcMwmLCZ2rkNKQp jgaMK1a8V/6F8pkYlDP4D3YLfajNn7VzIybXplQFTjThyaV79V8bZzigF869bhxhxtNW oPOVsRQQvSP9hTgzrJIKij8eN47h+5i7flB00nkhq3C0p7vPPck8qbKJorVzUgwnFhY1 DVOW+Mc2WkDf8xBSFWClSjc6qJetf0BdTl5GUgZ23DIithq+LpVdYczSaIVPwbF6lWHC SAIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726237451; x=1726842251; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YjwUwsr9pxU7mCEhFkg98Ymg5vreMKnsBqb+7RbbJI8=; b=uNHBvJ69oN7w4yrePGLpFZDlO3azAFwaLH1Qvd7GfVT7iy2kYe1FQ0EDOg2aqD1skh 0v3auHYbHOoEhFcodZizPpVbRFkObDNJFacXqBe7SUwRD9BZfQP5pYSNqn0XZQis+MK5 hzw4AjRN4/UlL+IiB7p+SjIa547DeOmP8knzYphmOb7+E4tpu/Uyij2icCaxIZpl/bfn UZ5KCtM/1h+K9dAkG4un1JBXgmF9PGD6UWy0ohgVbJba7jHyRZxTFyKF9bZgJgOtSPNQ J+xsW527glb4boPCMQQoE0/AjV0yp1cg+HrZdfF4nyjipQBmEVw6PJaogrE8PUrZxhvH 8G3g== X-Gm-Message-State: AOJu0Yxa7RTY31LiiQXE1R9uXT7vXgbNkITMo1quvn1MCGcERiSe0YMT rHgVBrhs8RVfh24jLdc6CdsoJ5oxe1GtDE9VwlZaUalD8Odm1VS6KSNZEg== X-Google-Smtp-Source: AGHT+IH+/pR6D6dDuasi/OysXTEvTURn1FfHzQ+kzA9XvrfRCSo5iO06XEhgB7h44bUiSqUIIASjxQ== X-Received: by 2002:adf:f68a:0:b0:374:cbdd:4813 with SMTP id ffacd0b85a97d-378d61f12e3mr1629130f8f.31.1726237450443; Fri, 13 Sep 2024 07:24:10 -0700 (PDT) Received: from lili.univ-paris-diderot.fr (roam-nat-fw-prg-194-254-61-42.net.univ-paris-diderot.fr. [194.254.61.42]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37895675cb5sm17251269f8f.53.2024.09.13.07.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 07:24:10 -0700 (PDT) From: Simon Tournier Date: Fri, 13 Sep 2024 16:24:06 +0200 Message-ID: X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -8.43 X-Migadu-Queue-Id: ECA901E1FC X-Spam-Score: -8.43 X-TUID: TlmGN4IJAGdi * guix/ui.scm (char-set:delimiters): New variable. (revelance)[string-match-term?]: New procedure. [score]: Use it. Change-Id: If2edc0e08b338a0064f73425db60d688c0535fb0 --- guix/ui.scm | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/guix/ui.scm b/guix/ui.scm index 966f0611f6..a8d1d120a4 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -1678,6 +1678,14 @@ (define* (package->recutils p port #:optional (width (terminal-columns)) ;;; Searching. ;;; +(define char-set:delimiters (char-set-xor + (char-set #\-) ;remove from punctuation + (char-set-union (char-set #\nul) + (char-set #\newline) + char-set:punctuation + char-set:symbol + char-set:whitespace))) + (define (relevance obj regexps metrics) "Compute a \"relevance score\" for OBJ as a function of its number of matches of REGEXPS and accordingly to METRICS. METRICS is list of @@ -1687,13 +1695,28 @@ (define (relevance obj regexps metrics) A score of zero means that OBJ does not match any of REGEXPS. The higher the score, the more relevant OBJ is to REGEXPS." + (define (string-match-term? regex-match str) + (let* ((start (match:start regex-match)) + (char:start (if (= 0 start) + #\nul + (string-ref str (1- start)))) + (end (match:end regex-match)) + (char:end (if (= end (string-length str)) + #\nul + (string-ref str end)))) + (and (char-set-contains? char-set:delimiters char:start) + (char-set-contains? char-set:delimiters char:end)))) + (define (score regexp str) (fold-matches regexp str 0 (lambda (m score) (+ score - (if (string=? (match:substring m) str) - 5 ;exact match - 1))))) + (cond + ((string=? (match:substring m) str) + 5) ;exact match + ((string-match-term? m str) + 3) ;XXX + (else 1)))))) (define (regexp->score regexp) (let ((score-regexp (lambda (str) (score regexp str)))) base-commit: 98bc13b9ea5f22a60de6c289d59072638001e08e prerequisite-patch-id: 912de410e3d8a0796e83bfa50047debb0030b624 prerequisite-patch-id: 9c72d45734a13bd80021b14b562ed1b6238aa7ca prerequisite-patch-id: 952cbe8dad322348d00f15125b512d34aaad8009 prerequisite-patch-id: fa6543fd5e6ec54a5036335aa5fa2b3a52675610 prerequisite-patch-id: cd68729ed441ec8235fde738e1f19669b570b099 prerequisite-patch-id: 53c5439602662bd61a3729aedf9327dfee5e9956 prerequisite-patch-id: a7edcd751c7a127f76b9c8e33ee425b6e800cfd7 prerequisite-patch-id: 29c1b2b9fcc017cff904ff3c1a32f65a6d54bad8 prerequisite-patch-id: 71757f95077bb7812f9d5a4e942c15b152ec7ac9 -- 2.45.2