fuzzyd 0.1.0-beta
fuzzy search library
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
fuzzyd
A D language fuzzy search library.
The algorithm used is a modified version of Smith–Waterman algorithm. The worst-case performance is O(m*n) for each entry provided in the input. (m and n are the respective length of the tested strings).
About
fuzzyd was primarily created to search matches in a list of files and commands.
Criteria
Score extra points when:
- pattern is found at the beggining of the string.
- pattern is at word boundary position.
- case sensitive matches.
Note: The algorithm examines all the occurrences of the provided pattern, making it slower but more accurate.
Usage
import fuzzyd;
string[] source = ["cd Documents"
,"curl localhost/foo"
,"rm -rf Downloads"
,"vi ~/Documents"];
auto fzs = fuzzy(source);
fzs("docts");
/* =>
[Result("cd Documents", 17, [0, 1, 3, 4, 5, 10, 11])
,Result("vi ~/Documents", 15, [5, 6, 7, 12, 13])
,Result("curl localhost/foo", 10, [0, 6, 7, 11, 12, 13, 16, 17])
,Result("rm -rf Downloads", 7, [7, 8, 12, 14, 15])
,Result("cp bar ../foo", 3, [0, 11, 12])]
*/
fzs("cp /foo");
/* =>
[Result("cp bar ../foo", 40, [0, 1, 2, 6, 9, 10, 11, 12])
,Result("curl localhost/foo", 35, [0, 4, 6, 7, 11, 14, 15, 16, 17])
,Result("rm -rf Downloads", 7, [2, 5, 6, 8, 12])
,Result("cd Documents", 5, [0, 2, 4, 5])
,Result("vi ~/Documents", 5, [2, 4, 6, 7])]
*/
Result struct:
struct Result {
string value; // entry tested against the provided string.
int score; // metrifies how "similar" the entry is. (Higher better)
int[] matches; // list of indexes of matched characters.
}
License
MIT
- Registered by Felipe Beline Baravieira
- 0.1.0-beta released 4 years ago
- fbeline/fuzzyd
- MIT
- Copyright © 2020, Felipe Beline Baravieira
- Authors:
- Dependencies:
- none
- Versions:
-
2.2.0-beta 2020-May-26 2.1.2-beta 2020-May-01 2.1.1-beta 2020-May-01 2.1.0-beta 2020-May-01 2.0.1-beta 2020-Apr-30 - Download Stats:
-
-
0 downloads today
-
2 downloads this week
-
12 downloads this month
-
463 downloads total
-
- Score:
- 0.9
- Short URL:
- fuzzyd.dub.pm