{"id":18542755,"url":"https://github.com/coinbase/fuzzy-trie","last_synced_at":"2025-04-09T18:32:10.044Z","repository":{"id":212712289,"uuid":"731731219","full_name":"coinbase/fuzzy-trie","owner":"coinbase","description":"A trie-based solution to provide fuzzy searching","archived":false,"fork":false,"pushed_at":"2025-03-13T00:29:31.000Z","size":33,"stargazers_count":10,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T10:38:47.572Z","etag":null,"topics":["fuzzy-trie"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coinbase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2023-12-14T18:40:04.000Z","updated_at":"2025-01-15T22:22:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"b66b0b0a-d4b0-46bd-b8ba-93441cfb45a0","html_url":"https://github.com/coinbase/fuzzy-trie","commit_stats":null,"previous_names":["coinbase/fuzzy-trie"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Ffuzzy-trie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Ffuzzy-trie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Ffuzzy-trie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Ffuzzy-trie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coinbase","download_url":"https://codeload.github.com/coinbase/fuzzy-trie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248087855,"owners_count":21045601,"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":["fuzzy-trie"],"created_at":"2024-11-06T20:10:24.366Z","updated_at":"2025-04-09T18:32:05.036Z","avatar_url":"https://github.com/coinbase.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fuzzy Trie\n\nA [trie](https://en.wikipedia.org/wiki/Trie)-based implementation of fuzzy searching.\n\nThis uses a [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) calculation to evaluate the closeness of an item in the tree to the search term.\n\n## Usage\n\nThe items to be loaded into the tree must implement the `Fuzzable` interface defined in this library.\n\nOnce you have implemented that interface for your items to be loaded into the tree, you can do the following:\n\n```\nctx := context.Background()\nfuzzables := getMyItems() // returns structs that implement Fuzzable - not Fuzzable, as this must also satisfy ComparableFuzzable\ntree := trie.LoadTree(ctx, fuzzables, func(ctx context.Context, item *myFuzzableImpl) (string, error) {\n    return item.trieNodeKey, nil\n})\nsearchableTree := trie.NewDistanceTrees([]*trie.Tree[*myFuzzableImpl]{tree})\nsearchResults, err := searchableTree.Search(ctx, \"cat\")\n```\n\n### Multi-Dimensional Trees\n\nIf you wish to evaluate _closeness_ to your search term with multiple fields on your items (e.g., perhaps supporting search by a family name and then using relevance of given name as a tie-breaker), you can provide multiple trees to the `DistanceTree` to execute such functionality:\n\n```\nctx := context.Background()\npeople := getPeople() // struct defined as { familyName string, givenName string }\nfamilyNameTree := trie.LoadTree(ctx, people, func(ctx context.Context, item *person) (string, error) {\n    return person.familyName, nil\n})\ngivenNameTree := trie.LoadTree(ctx, people, func(ctx context.Context, item *person) (string, error) {\n    return person.givenName, nil\n})\nsearchableTree := trie.NewDistanceTrees([]*trie.Tree[*person]{familyNameTree, givenNameTree})\nsearchResults, err := searchableTree.Search(ctx, \"jo\")\n```\n\nThe above tree will first find results that have a family name close to 'jo' and, for cases where multiple people are equally close to that search term, will then evaluate the closeness of the person's given name to 'jo' and return the results in that order.\n\n### Measurement\n\nIf you wish to measure the performance of this tree within your application, you can supply an implementation of the `trie.Timer` interface provided in this library and use the `SetTimer` method on the `DistanceTrees` struct to inject your implementation.\n\n## Benchmarking\n\nRefer to [benchmarking.md](./internal/benchmark/benchmarking.md) for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase%2Ffuzzy-trie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoinbase%2Ffuzzy-trie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase%2Ffuzzy-trie/lists"}