{"id":18427161,"url":"https://github.com/fjebaker/fuzzig","last_synced_at":"2025-04-07T16:33:13.070Z","repository":{"id":231789302,"uuid":"782726421","full_name":"fjebaker/fuzzig","owner":"fjebaker","description":"Fuzzy finder algorithms a la Smith-Waterman for Zig.","archived":false,"fork":false,"pushed_at":"2024-08-15T09:06:43.000Z","size":105,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-15T10:41:16.579Z","etag":null,"topics":["alignment","fuzzy-finder","fuzzy-search","fzf","smith-waterman","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fjebaker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-05T22:27:07.000Z","updated_at":"2024-08-15T09:06:48.000Z","dependencies_parsed_at":"2024-04-06T00:24:42.228Z","dependency_job_id":"c8cb012f-f1b7-4893-903a-7c74de5add9b","html_url":"https://github.com/fjebaker/fuzzig","commit_stats":null,"previous_names":["fjebaker/fuzzig"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjebaker%2Ffuzzig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjebaker%2Ffuzzig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjebaker%2Ffuzzig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjebaker%2Ffuzzig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fjebaker","download_url":"https://codeload.github.com/fjebaker/fuzzig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223286384,"owners_count":17120000,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alignment","fuzzy-finder","fuzzy-search","fzf","smith-waterman","zig"],"created_at":"2024-11-06T05:09:49.631Z","updated_at":"2025-04-07T16:33:13.063Z","avatar_url":"https://github.com/fjebaker.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fuzzig\n\nFuzzy finder algorithms in Zig based on the [Smith-Waterman algorithm](https://en.wikipedia.org/wiki/Smith%E2%80%93Waterman_algorithm), inspired by [fzf](https://github.com/junegunn/fzf).\n\nFor Unicode support, use the [unicode branch](https://github.com/fjebaker/fuzzig/tree/unicode).\n\n## Example\n\n```zig\nconst std = @import(\"std\");\nconst fuzzig = @import(\"fuzzig\");\n\npub fn main() !void {\n    var gpa = std.heap.GeneralPurposeAllocator(.{}){};\n    defer _ = gpa.deinit();\n    const allocator = gpa.allocator();\n\n    // The default implementation needs to know the maximum haystack and needle\n    // sizes so that it can allocate all memory contiguously. Smaller haystack\n    // or needle strings will use subsets of the allocated memory.\n    var searcher = try fuzzig.Ascii.init(\n        allocator,\n        128, // haystack max size\n        32, // needle max size\n        .{ .case_sensitive = false },\n    );\n    defer searcher.deinit();\n\n    const haystack = \"Hello World\";\n    const needle = \"world\";\n\n    const score = searcher.score(haystack, needle);\n    std.debug.print(\"Score: {d}\\n\", .{score.?});\n\n    // Get a traceback of the character positions that were matched\n    const match = searcher.scoreMatches(haystack, needle);\n    std.debug.print(\n        \"Score with traceback: {d} {any}\\n\",\n        .{ match.score.?, match.matches },\n    );\n}\n```\n\nOutput\n\n```\nScore: 104\nScore with traceback: 104 { 6, 7, 8, 9, 10 }\n```\n\nThe traceback shows the indices of the haystack that were matched, useful for generating visual feedback.\n\nSee the [`AsciiOptions` struct](https://github.com/fjebaker/fuzzig/blob/a78afddec30b547643604aafaee202db6fc878f1/src/root.zig#L460-L466) for a list of available options.\n\n## Design\n\nThe module defines an `Algorithm` generic type, which accepts the element type of the array to be fuzzy searched, the score type and values, and an algorithm implementation. The implementation must define an `eqlFunc`, a `scoreFunc` and a `bonusFunc` used to test for equality between tokens, for determining the score of two matching tokens, and for determining any in-places bonuses respectively.\n\n- Algorithms only have `score` and `scoreMatches` as public functions.\n- If not matches are detected, the score will be `null`.\n\n## Usage\n\nThe library was written with Zig 0.12.0-dev.3541+05b185811, but there is likely a lot of flexibility with versioning.\n\n- Currently supported version: Zig 0.14.0-dev.2628+5b5c60f43\n\nTo use in a Zig project, add it to your `build.zig.zon`\n\n```zig\n    // ...\n    .dependencies = .{\n        .fuzzig = .{\n            .url = \"https://github.com/fjebaker/fuzzig/archive/main.tar.gz\",\n            .hash = \"\" // get with `zig fetch`\n        },\n    },\n    // ...\n```\n\nThen add the module to your build step in `build.zig`:\n\n```zig\n    // ...\n    const fuzzig = b.dependency(\"fuzzig\", .{}).module(\"fuzzig\");\n\n    my_exe_or_lib.root_module.addImport(\"fuzzig\", fuzzig);\n    // ...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffjebaker%2Ffuzzig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffjebaker%2Ffuzzig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffjebaker%2Ffuzzig/lists"}