[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/flx 955772f489 029/182: optimize full-match boost
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/flx 955772f489 029/182: optimize full-match boost |
Date: |
Tue, 13 Dec 2022 03:59:22 -0500 (EST) |
branch: elpa/flx
commit 955772f489300212a18d058ae7d3ee01e0e26847
Author: Le Wang <le.wang@agworld.com.au>
Commit: Le Wang <le.wang@agworld.com.au>
optimize full-match boost
---
flx.el | 11 ++++++++---
tests/flx-test.el | 26 +++++++++++++++++---------
2 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/flx.el b/flx.el
index 102b5db2cb..cda9c04a8e 100644
--- a/flx.el
+++ b/flx.el
@@ -13,7 +13,7 @@
;; Version: 0.1
;; Last-Updated:
;; By:
-;; Update #: 6
+;; Update #: 11
;; URL:
;; Keywords:
;; Compatibility:
@@ -285,10 +285,15 @@ e.g. (\"aab\" \"ab\") returns
(let* ((info-hash (flx-process-cache str cache))
(heatmap (gethash 'heatmap info-hash))
(matches (flx-get-matches info-hash query))
+ (query-length (length query))
+ (full-match-boost (and (< query-length 5)
+ (> query-length 1)))
(best-score nil))
(mapc (lambda (match-positions)
- (let ((score (if (= (length match-positions)
- (length str))
+ (let ((score (if (and
+ full-match-boost
+ (= (length match-positions)
+ (length str)))
10000
0))
(contiguous-count 0)
diff --git a/tests/flx-test.el b/tests/flx-test.el
index e4035bd51e..ec03f0ceba 100644
--- a/tests/flx-test.el
+++ b/tests/flx-test.el
@@ -13,7 +13,7 @@
;; Version: 0.1
;; Last-Updated:
;; By:
-;; Update #: 5
+;; Update #: 7
;; URL:
;; Keywords:
;; Compatibility:
@@ -169,13 +169,6 @@
(car string-score)))))
-(ert-deftest flx-basename-entire ()
- "whole match is preferred"
- (let* ((query "a")
- (higher (flx-score "a" query (flx-make-filename-cache)))
- (lower (flx-score "ab" query (flx-make-filename-cache))))
- (should (> (car higher) (car lower)))))
-
(ert-deftest flx-basename-order ()
"index of match matters"
(let* ((query "a")
@@ -191,13 +184,28 @@
(should (> (car higher) (car lower)))))
-(ert-deftest flx-entire-match ()
+(ert-deftest flx-entire-match-1 ()
+ "whole match is preferred"
+ (let* ((query "a")
+ (higher (flx-score "a" query (flx-make-filename-cache)))
+ (lower (flx-score "ab" query (flx-make-filename-cache))))
+ (should (> (car higher) (car lower)))))
+
+(ert-deftest flx-entire-match-3 ()
"when entire string is match, it shoud overpower acronym matches"
(let* ((query "rss")
(higher (flx-score "rss" query (flx-make-filename-cache)))
(lower (flx-score "rff-sff-sff" query (flx-make-filename-cache))))
(should (> (car higher) (car lower)))))
+(ert-deftest flx-entire-match-5 ()
+ "when entire string is match, 4 letters is the cutoff when
+substring can overpower abbreviation."
+ (let* ((query "rssss")
+ (higher (flx-score "rssss" query (flx-make-filename-cache)))
+ (lower (flx-score "rff-sff-sff-sff-sff" query
(flx-make-filename-cache))))
+ (should (> (car higher) (car lower)))))
+
;;;;;;;;;;;;;;
;; advanced ;;
;;;;;;;;;;;;;;
- [nongnu] elpa/flx fb1ded43df 044/182: cache cons cell lists too, (continued)
- [nongnu] elpa/flx fb1ded43df 044/182: cache cons cell lists too, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx d21ac098df 050/182: add option `flx-ido-use-faces', ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx f9bd16221b 063/182: update large collection guidelines, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 27bc47899a 075/182: Merge pull request #37 from artagnon/make, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx abe1a77c02 081/182: Merge pull request #38 from artagnon/cl-lib, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 9200e27309 083/182: use "flex" filtering when collection too large, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx c85273a6e8 009/182: fix helm demo typo, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 7110df04e2 005/182: update tests, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx fabca711e9 013/182: fix typo, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx dc739574ad 011/182: add helm demo without flx, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 955772f489 029/182: optimize full-match boost,
ELPA Syncer <=
- [nongnu] elpa/flx 0519734c5b 030/182: consider runs of capitals to be same word, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx e80bc0dea4 018/182: more ido optimizations, refactor out flx-propertize, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx a31814e5ef 031/182: update README to say alpha, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 5ab18c3101 024/182: fix over manipulation of strings, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx fd10bf595d 025/182: fix typo, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx af1010e4ad 035/182: Reverting "fix `ido-merge-work-directories`", ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 11f3fad14f 041/182: get complete cache key more smartly, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx c6601c7162 022/182: readme update, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx a13d654096 045/182: disable caching for files/dirs for now, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 1f175f3c65 047/182: add comment about disabling ido faces, ELPA Syncer, 2022/12/13