{"id":24326553,"url":"https://github.com/snapp-incubator/go-symspell","last_synced_at":"2025-09-27T11:30:30.001Z","repository":{"id":270690060,"uuid":"911166920","full_name":"snapp-incubator/go-symspell","owner":"snapp-incubator","description":"SymSpell: 1 million times faster spelling correction \u0026 fuzzy search through Symmetric Delete spelling correction algorithm","archived":false,"fork":false,"pushed_at":"2025-01-04T11:26:55.000Z","size":3133,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-04T12:34:54.193Z","etag":null,"topics":["damerau-levenshtein","fuzzy-matching","fuzzy-search","levenshtein","spell-checker","spellcheck","spelling","symspell"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snapp-incubator.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":"2025-01-02T11:47:46.000Z","updated_at":"2025-01-04T11:26:59.000Z","dependencies_parsed_at":"2025-01-04T12:36:11.895Z","dependency_job_id":null,"html_url":"https://github.com/snapp-incubator/go-symspell","commit_stats":null,"previous_names":["snapp-incubator/symspell","snapp-incubator/go-symspell"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snapp-incubator%2Fgo-symspell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snapp-incubator%2Fgo-symspell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snapp-incubator%2Fgo-symspell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snapp-incubator%2Fgo-symspell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snapp-incubator","download_url":"https://codeload.github.com/snapp-incubator/go-symspell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234429254,"owners_count":18831241,"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":["damerau-levenshtein","fuzzy-matching","fuzzy-search","levenshtein","spell-checker","spellcheck","spelling","symspell"],"created_at":"2025-01-17T21:12:59.737Z","updated_at":"2025-09-27T11:30:29.502Z","avatar_url":"https://github.com/snapp-incubator.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SymSpell Package\n[![GoDoc](https://godoc.org/github.com/snapp-incubator/go-symspell?status.svg)](https://pkg.go.dev/github.com/snapp-incubator/go-symspell)\n[![Go Report Card](https://goreportcard.com/badge/github.com/snapp-incubator/go-symspell)](https://goreportcard.com/report/github.com/snapp-incubator/go-symspell)\n\n## Overview\n\nThe `symspell` package provides a Golang implementation of the SymSpell algorithm, a fast and memory-efficient algorithm\nfor spelling correction, word segmentation, and fuzzy string matching. It supports both unigrams and bigrams for\nadvanced contextual correction.\n\n## Features\n\n- Fast lookup for single-word corrections\n- Compound word corrections\n- Customizable edit distance and prefix length\n- Support for unigram and bigram dictionaries\n- Configurable thresholds for performance tuning\n\n## Installation\n\nInstall the package using `go get`:\n\n```sh\ngo get github.com/snapp-incubator/go-symspell\n```\n\n## Usage\n\n- Import the Package\n\n- import \"github.com/snapp-incubator/go-symspell\"\n\n- Initialize SymSpell\n\n- Simple Lookup\n\n##### Lookup\n\n###### Load a unigram dictionary:\n\n```go\npackage main\n\nimport \"github.com/snapp-incubator/go-symspell\"\n\nfunc main() {\n    symSpell := symspell.NewSymSpellWithLoadDictionary(\"path/to/vocab.txt\", 0, 1,\n        symspell.WithCountThreshold(10),\n        symspell.WithMaxDictionaryEditDistance(3),\n        symspell.WithPrefixLength(5),\n    )\n}\n```\n\n##### Compound Lookup\n\n###### Load both unigram and bigram dictionaries:\n\n```go\npackage main\n\nfunc main()  {\n    symSpell := symspell.NewSymSpellWithLoadBigramDictionary(\"path/to/vocab.txt\", \"path/to/vocab_bigram.txt\", 0, 1,\n        symspell.WithCountThreshold(1),\n        symspell.WithMaxDictionaryEditDistance(3),\n        symspell.WithPrefixLength(7),\n    )\n}\n```\n\n\n### Perform Lookup\n\n#### Single Word Lookup\n```go\nsuggestions, err := symSpell.Lookup(\"حیابان\", symspell.Top, 3)\nif err != nil {\n    log.Fatal(err)\n}\nfmt.Println(suggestions[0].Term) // Output: خیابان\n```\n\nCompound Word Lookup\n```go\nsuggestion := symSpell.LookupCompound(\"حیابان ملاصدزا\", 3)\nfmt.Println(suggestion.Term) // Output: خیابان ملاصدرا\n```\n\n## Examples\n\n#### Unit Tests\n\nThe repository includes comprehensive unit tests. Run the tests with:\n```shell\ngo test ./...\n```\n\nExample test cases include single-word corrections, compound word corrections, and edge cases.\n\n### Configuration Options\n- WithMaxDictionaryEditDistance: Sets the maximum edit distance for corrections.\n- WithPrefixLength: Sets the prefix length for index optimization.\n- WithCountThreshold: Filters dictionary entries with low frequency.\n\nDictionaries\n\nThe dictionaries should be formatted as plain text files:\n- Unigram file: Each line should contain a term and its frequency, separated by a space.(or could be custom seperator)\n- Bigram file: Each line should contain two terms and their frequency, separated by a space.\n\n#### Example:\n\nUnigram (vocab.txt):\n```text\nخیابان 1000\nمیدان 800\n```\n\nBigram (vocab_bigram.txt):\n```text\nخیابان کارگر 500\nمیدان آزادی 300\n```\n\n### Performance\n\nSymSpell is optimized for speed and memory efficiency. For large vocabularies, tune maxEditDistance, prefixLength, and\ncountThreshold to balance performance and accuracy.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnapp-incubator%2Fgo-symspell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnapp-incubator%2Fgo-symspell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnapp-incubator%2Fgo-symspell/lists"}