The fuzzy-match Reference Manual

This is the fuzzy-match Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 16:28:07 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 fuzzy-match

From a string input and a list of candidates, return the most relevant candidates first.

Maintainer

vindarel <>

Author

Nyxt project, Ambrevar, Vindarel

Home Page

https://github.com/vindarel/fuzzy-match

Source Control

(GIT git@github.com:vindarel/fuzzy-match.git)

Bug Tracker

https://github.com/vindarel/fuzzy-match/issues

License

MIT

Long Description

# Fuzzy-match

Fuzzy match candidates from an input string.

On Quicklisp (2020-12) and [Ultralisp](https://ultralisp.org/).

~~~lisp
CL-USER> (fuzzy-match "hl" ’("foo" "bar" "hello" "hey!"))
("hello" "hey!" "foo" "bar")
~~~

~~~lisp
CL-USER> (fuzzy-match "zp" ’("foo" "zepellin" "bar: zep"))
("zepellin" "bar: zep" "foo")
~~~

The parameters are hand-picked for the results to feel natural. A
candidate that starts with the input substring should appear
first. For example, we use the Damerau-Levenshtein distance thanks to
the ‘MK-STRING-METRICS‘ library under the hood, but we don’t obey to
its result.

To give any objects as candidates, and not only strings, make them
implement ‘object-display‘, that returns a string representation.

# Nyxt origin

This code was extracted from the Nyxt browser. Original authors: Ambrevar, Vindarel.

# Licence

MIT

Version

0.1

Dependencies
  • str (system).
  • mk-string-metrics (system).
Source

fuzzy-match.asd.

Child Component

fuzzy-match.lisp (file).


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 fuzzy-match/fuzzy-match.asd

Source

fuzzy-match.asd.

Parent Component

fuzzy-match (system).

ASDF Systems

fuzzy-match.


3.1.2 fuzzy-match/fuzzy-match.lisp

Source

fuzzy-match.asd.

Parent Component

fuzzy-match (system).

Packages

fuzzy-match.

Public Interface

fuzzy-match (function).

Internals

4 Packages

Packages are listed by definition order.


4.1 fuzzy-match

Source

fuzzy-match.lisp.

Use List

common-lisp.

Public Interface

fuzzy-match (function).

Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Ordinary functions

Function: fuzzy-match (input suggestions &key suggestions-display)

From the user input and a list of suggestions, return a filtered list of suggestions that have all the input words in them, and sort this list to have the ’most relevant’ first.
The match is case-sensitive if INPUT contains at least one uppercase character. SUGGESTIONS-DISPLAY can be used to pass the pre-computed display strings of the suggestions; otherwise ‘object-display’ is used.

Package

fuzzy-match.

Source

fuzzy-match.lisp.


5.2 Internals


5.2.1 Special variables

Special Variable: score-threshold

The threshold under which suggestions are eleminated.

Package

fuzzy-match.

Source

fuzzy-match.lisp.


5.2.2 Ordinary functions

Function: file-suggestion-function (input files)

Fuzzy-match this list of files.

Package

fuzzy-match.

Source

fuzzy-match.lisp.

Function: find-exactly-matching-substrings (input suggestions &key substring-length)

Return the list of input substrings that match at least one suggestion. The substrings must be SUBSTRING-LENGTH characters long or more.

Package

fuzzy-match.

Source

fuzzy-match.lisp.

Function: keep-exact-matches-in-suggestions (input suggestion-pairs)

Destructively filter out non-exact matches from suggestions.
If any input substring matches exactly (but not necessarily a whole word),
then all suggestions that are not exactly matched by at least one substring are removed.

Package

fuzzy-match.

Source

fuzzy-match.lisp.

Function: score-suggestion (input suggestion)

Return a SUGGESTION’s score for INPUT.
A higher score means the suggestion comes first.

Package

fuzzy-match.

Source

fuzzy-match.lisp.

Function: sort-suggestions (input suggestion-pairs)

Sort SUGGESTION-PAIRS, the pair closest to INPUT in the levenshtein distance comes first. SUGGESTION-PAIRS is a list of (display-value real-value). See ‘fuzzy-match’ for
more details.

Package

fuzzy-match.

Source

fuzzy-match.lisp.

Function: substring-norm (substrings string &key substring-length)

Return the norm of SUBSTRINGS with regard to STRING.
The norm is closer to 1 if
- substrings start near the beginning of STRING;
- substrings length are closer to the length of STRING.

Only substrings of SUBSTRING-LENGTH characters or more are considered.

Package

fuzzy-match.

Source

fuzzy-match.lisp.

Function: to-unicode (input)

Convert INPUT to (simple-array character) type.

Package

fuzzy-match.

Source

fuzzy-match.lisp.


5.2.3 Generic functions

Generic Function: object-display (obj)
Package

fuzzy-match.

Methods
Method: object-display (obj)

Like ‘print-object’, but for fuzzy-match.

Source

fuzzy-match.lisp.


Appendix A Indexes


A.1 Concepts