{"id":22286427,"url":"https://github.com/alexcorvi/spelt","last_synced_at":"2025-09-04T19:24:59.315Z","repository":{"id":57367375,"uuid":"87212895","full_name":"alexcorvi/spelt","owner":"alexcorvi","description":"Fast \u0026 accurate spellchecker for node.js ","archived":false,"fork":false,"pushed_at":"2017-04-05T22:26:59.000Z","size":1015,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-23T03:26:35.247Z","etag":null,"topics":["spell","spellcheck","spellchecker","spelling"],"latest_commit_sha":null,"homepage":"http://spelt-demo.surge.sh/","language":"JavaScript","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/alexcorvi.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-04T16:55:49.000Z","updated_at":"2024-04-09T22:05:35.000Z","dependencies_parsed_at":"2022-08-23T19:30:18.547Z","dependency_job_id":null,"html_url":"https://github.com/alexcorvi/spelt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcorvi%2Fspelt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcorvi%2Fspelt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcorvi%2Fspelt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcorvi%2Fspelt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexcorvi","download_url":"https://codeload.github.com/alexcorvi/spelt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227552871,"owners_count":17786121,"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":["spell","spellcheck","spellchecker","spelling"],"created_at":"2024-12-03T16:55:53.284Z","updated_at":"2024-12-03T16:55:53.409Z","avatar_url":"https://github.com/alexcorvi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spelt\n\nJavaScript english spellchecker written in TypeScript.\n\nDemo: [http://spelt-demo.surge.sh/](http://spelt-demo.surge.sh/)\n\n## Installation\n\n#### Install the spell checker via NPM\n\n```\nnpm i --save spelt\n```\n\n\n#### Install one of the dictionaries\n\n- British English dictionary\n```\nnpm i --save spelt-gb-dict\n```\n\n- American English dictionary\n```\nnpm i --save spelt-us-dict\n```\n\n- Canadian English dictionary\n```\nnpm i --save spelt-ca-dict\n```\n\n- Australian English dictionary\n```\nnpm i --save spelt-au-dict\n```\n\n## Usage\n\n```typescript\n// import the lib\nimport spelt from \"spelt\";\n// import one of the dictionaries\nimport {dictionary} from \"spelt-gb-dict\";\n// build dictionary\nconst check = spelt({\n\tdictionary:dictionary,\n\t// can be either \"gb\" or \"us\"\n\tdistanceThreshold:0.2\n\t// when a correction found with this distance\n\t// we'll stop looking for another\n\t// this would improve performance\n});\n\nconsole.log(check(\"heve\"));\n```\n\nThe above code would output:\n\n```javascript\n{\n\t// the raw input\n\traw:\"heve\",\n\t// correct or not\n\tcorrect:false\n\t// corrections array sorted by string distance\n\t[\n\t\t{\n\t\t\t// possible correction\n\t\t\tcorrection:\"have\",\n\t\t\t// distance from the input word\n\t\t\tdistance:0.4\n\t\t},\n\t\t// .... other possible corrections\n\t]\n}\n```\n\n## How it works\n\n![how it works](./how.png)\n\n## String Distance\n\nI've noticed that a lot of spellcheckers are using the __levenshtein distance (LD)__, I don't think it's the appropriate solution, since it doesn't take moving a two letters around in consideration.\n\nFor example:\n1. the distance between `abcde` and `abcxx` is `2`.\n2. the distance between `abcde` and `abced` is also `2`.\n\nBut on the first case we introduced two new letters, and removed two letters! while on the second case we just moved the `e` and `d` around without introducing or removing any letter.\n\nSo in short, I don't see the levenshtein distance as an appropriate solution for a spellchecker.\n\nI've wrote my own string distance calculator and you can find it [here](https://github.com/FinNLP/strdistance).\n\n## Performance\n\n- __Spellchecking a book:__ Processing H.G Wells Novel _The Time Machine_ with (1000s of misspellings introduced took about 8 seconds), in a rate of __4K words/second__.\n- __[Spellchecking Wikipedia list](http://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines):__ Processing about 4 thousands words, all misspelt, took about 3.5 seconds with a rate of __2.3K word/second__.\n\nThis is not very impressive, but I'm working on it. However, it's far better than [Norvig's](http://norvig.com/spell-correct.html) spellchecker.\n\n## Accuracy\n\nRunning on [wikipedia's list](http://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines), with a distance threshold of `0`, It was able to find the accurate correction in the first 5 suggestions on __85%__ of the cases.\n\n## License\n\nThe MIT License","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexcorvi%2Fspelt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexcorvi%2Fspelt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexcorvi%2Fspelt/lists"}