{"id":13511640,"url":"https://github.com/client9/misspell","last_synced_at":"2025-03-25T23:16:08.462Z","repository":{"id":38325074,"uuid":"48780094","full_name":"client9/misspell","owner":"client9","description":"Correct commonly misspelled English words in source files","archived":false,"fork":false,"pushed_at":"2024-06-12T03:19:38.000Z","size":2283,"stargazers_count":1369,"open_issues_count":76,"forks_count":118,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-20T22:19:15.108Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","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/client9.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":"2015-12-30T03:38:05.000Z","updated_at":"2025-03-14T13:09:25.000Z","dependencies_parsed_at":"2024-09-17T00:27:47.944Z","dependency_job_id":"c7a43d68-958c-4862-8c87-ca173dfc6b15","html_url":"https://github.com/client9/misspell","commit_stats":{"total_commits":498,"total_committers":13,"mean_commits":38.30769230769231,"dds":0.05622489959839361,"last_synced_commit":"c0b55c8239520f6b5aa15a0207ca8b28027ba49e"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/client9%2Fmisspell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/client9%2Fmisspell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/client9%2Fmisspell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/client9%2Fmisspell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/client9","download_url":"https://codeload.github.com/client9/misspell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245556975,"owners_count":20634896,"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":[],"created_at":"2024-08-01T03:01:02.705Z","updated_at":"2025-03-25T23:16:08.439Z","avatar_url":"https://github.com/client9.png","language":"Go","readme":"[![Build Status](https://travis-ci.org/client9/misspell.svg?branch=master)](https://travis-ci.org/client9/misspell) [![Go Report Card](https://goreportcard.com/badge/github.com/client9/misspell)](https://goreportcard.com/report/github.com/client9/misspell) [![GoDoc](https://godoc.org/github.com/client9/misspell?status.svg)](https://godoc.org/github.com/client9/misspell) [![Coverage](http://gocover.io/_badge/github.com/client9/misspell)](http://gocover.io/github.com/client9/misspell) [![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://raw.githubusercontent.com/client9/misspell/master/LICENSE)\n\nCorrect commonly misspelled English words... quickly.\n\n### Install\n\n\nIf you just want a binary and to start using `misspell`:\n\n```\ncurl -L -o ./install-misspell.sh https://git.io/misspell\nsh ./install-misspell.sh\n```\n\n\nBoth will install as `./bin/misspell`.  You can adjust the download location using the `-b` flag.   File a ticket if you want another platform supported.\n\n\nIf you use [Go](https://golang.org/), the best way to run `misspell` is by using [gometalinter](#gometalinter).  Otherwise, install `misspell` the old-fashioned way:\n\n```\ngo get -u github.com/client9/misspell/cmd/misspell\n```\n\nand misspell will be in your `GOPATH`\n\n\nAlso if you like to live dangerously, one could do\n\n```bash\ncurl -L https://git.io/misspell | bash\n```\n\n### Usage\n\n\n```bash\n$ misspell all.html your.txt important.md files.go\nyour.txt:42:10 found \"langauge\" a misspelling of \"language\"\n\n# ^ file, line, column\n```\n\n```\n$ misspell -help\nUsage of misspell:\n  -debug\n    \tDebug matching, very slow\n  -error\n    \tExit with 2 if misspelling found\n  -f string\n    \t'csv', 'sqlite3' or custom Golang template for output\n  -i string\n    \tignore the following corrections, comma separated\n  -j int\n    \tNumber of workers, 0 = number of CPUs\n  -legal\n    \tShow legal information and exit\n  -locale string\n    \tCorrect spellings using locale perferances for US or UK.  Default is to use a neutral variety of English.  Setting locale to US will correct the British spelling of 'colour' to 'color'\n  -o string\n    \toutput file or [stderr|stdout|] (default \"stdout\")\n  -q\tDo not emit misspelling output\n  -source string\n    \tSource mode: auto=guess, go=golang source, text=plain or markdown-like text (default \"auto\")\n  -w\tOverwrite file with corrections (default is just to display)\n```\n\n## FAQ\n\n* [Automatic Corrections](#correct)\n* [Converting UK spellings to US](#locale)\n* [Using pipes and stdin](#stdin)\n* [Golang special support](#golang)\n* [gometalinter support](#gometalinter)\n* [CSV Output](#csv)\n* [Using SQLite3](#sqlite)\n* [Changing output format](#output)\n* [Checking a folder recursively](#recursive)\n* [Performance](#performance)\n* [Known Issues](#issues)\n* [Debugging](#debug)\n* [False Negatives and missing words](#missing)\n* [Origin of Word Lists](#words)\n* [Software License](#license)\n* [Problem statement](#problem)\n* [Other spelling correctors](#others)\n* [Other ideas](#otherideas)\n\n\u003ca name=\"correct\"\u003e\u003c/a\u003e\n### How can I make the corrections automatically?\n\nJust add the `-w` flag!\n\n```\n$ misspell -w all.html your.txt important.md files.go\nyour.txt:9:21:corrected \"langauge\" to \"language\"\n\n# ^ File is rewritten only if a misspelling is found\n```\n\n\u003ca name=\"locale\"\u003e\u003c/a\u003e\n### How do I convert British spellings to American (or vice-versa)?\n\nAdd the `-locale US` flag!\n\n```bash\n$ misspell -locale US important.txt\nimportant.txt:10:20 found \"colour\" a misspelling of \"color\"\n```\n\nAdd the `-locale UK` flag!\n\n```bash\n$ echo \"My favorite color is blue\" | misspell -locale UK\nstdin:1:3:found \"favorite color\" a misspelling of \"favourite colour\"\n```\n\nHelp is appreciated as I'm neither British nor an\nexpert in the English language.\n\n\u003ca name=\"recursive\"\u003e\u003c/a\u003e\n### How do you check an entire folder recursively?\n\nJust list a directory you'd like to check\n\n```bash\nmisspell .\nmisspell aDirectory anotherDirectory aFile\n```\n\nYou can also run misspell recursively using the following shell tricks:\n\n```bash\nmisspell directory/**/*\n```\n\nor\n\n```bash\nfind . -type f | xargs misspell\n```\n\nYou can select a type of file as well.  The following examples selects all `.txt` files that are *not* in the `vendor` directory:\n\n```bash\nfind . -type f -name '*.txt' | grep -v vendor/ | xargs misspell -error\n```\n\n\u003ca name=\"stdin\"\u003e\u003c/a\u003e\n### Can I use pipes or `stdin` for input?\n\nYes!\n\nPrint messages to `stderr` only:\n\n```bash\n$ echo \"zeebra\" | misspell\nstdin:1:0:found \"zeebra\" a misspelling of \"zebra\"\n```\n\nPrint messages to `stderr`, and corrected text to `stdout`:\n\n```bash\n$ echo \"zeebra\" | misspell -w\nstdin:1:0:corrected \"zeebra\" to \"zebra\"\nzebra\n```\n\nOnly print the corrected text to `stdout`:\n\n```bash\n$ echo \"zeebra\" | misspell -w -q\nzebra\n```\n\n\u003ca name=\"golang\"\u003e\u003c/a\u003e\n### Are there special rules for golang source files?\n\nYes!  If the file ends in `.go`, then misspell will only check spelling in\ncomments.\n\nIf you want to force a file to be checked as a golang source, use `-source=go`\non the command line.  Conversely, you can check a golang source as if it were\npure text by using `-source=text`.  You might want to do this since many\nvariable names have misspellings in them!\n\n### Can I check only-comments in other other programming languages?\n\nI'm told the using `-source=go` works well for ruby, javascript, java, c and\nc++.\n\nIt doesn't work well for python and bash.\n\n\u003ca name=\"gometalinter\"\u003e\u003c/a\u003e\n### Does this work with gometalinter?\n\n[gometalinter](https://github.com/alecthomas/gometalinter) runs\nmultiple golang linters.  Starting on [2016-06-12](https://github.com/alecthomas/gometalinter/pull/134)\ngometalinter supports `misspell` natively but it is disabled by default.\n\n```bash\n# update your copy of gometalinter\ngo get -u github.com/alecthomas/gometalinter\n\n# install updates and misspell\ngometalinter --install --update\n```\n\nTo use, just enable `misspell`\n\n```\ngometalinter --enable misspell ./...\n```\n\nNote that gometalinter only checks golang files, and uses the default options\nof `misspell`\n\nYou may wish to run this on your plaintext (.txt) and/or markdown files too.\n\n\n\u003ca name=\"csv\"\u003e\u003c/a\u003e\n### How Can I Get CSV Output?\n\nUsing `-f csv`, the output is standard comma-seprated values with headers in the first row.\n\n```\nmisspell -f csv *\nfile,line,column,typo,corrected\n\"README.md\",9,22,langauge,language\n\"README.md\",47,25,langauge,language\n```\n\n\u003ca name=\"sqlite\"\u003e\u003c/a\u003e\n### How can I export to SQLite3? \n\nUsing `-f sqlite`, the output is a [sqlite3](https://www.sqlite.org/index.html) dump-file.\n\n```bash\n$ misspell -f sqlite * \u003e /tmp/misspell.sql\n$ cat /tmp/misspell.sql\n\nPRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\nCREATE TABLE misspell(\n  \"file\" TEXT,\n  \"line\" INTEGER,i\n  \"column\" INTEGER,i\n  \"typo\" TEXT,\n  \"corrected\" TEXT\n);\nINSERT INTO misspell VALUES(\"install.txt\",202,31,\"immediatly\",\"immediately\");\n# etc...\nCOMMIT;\n```\n\n```bash\n$ sqlite3 -init /tmp/misspell.sql :memory: 'select count(*) from misspell'\n1\n```\n\nWith some tricks you can directly pipe output to sqlite3 by using `-init /dev/stdin`:\n\n```\nmisspell -f sqlite * | sqlite3 -init /dev/stdin -column -cmd '.width 60 15' ':memory' \\\n    'select substr(file,35),typo,count(*) as count from misspell group by file, typo order by count desc;'\n```\n\n\u003ca name=\"ignore\"\u003e\u003c/a\u003e\n### How can I ignore rules?\n\nUsing the `-i \"comma,separated,rules\"` flag you can specify corrections to ignore.\n\nFor example, if you were to run `misspell -w -error -source=text` against document that contains the string `Guy Finkelshteyn Braswell`, misspell would change the text to `Guy Finkelstheyn Bras well`.  You can then\ndetermine the rules to ignore by reverting the change and running the with the `-debug` flag.  You can then see\nthat the corrections were `htey -\u003e they` and `aswell -\u003e as well`. To ignore these two rules, you add `-i \"htey,aswell\"` to\nyour command. With debug mode on, you can see it print the corrections, but it will no longer make them.\n\n\u003ca name=\"output\"\u003e\u003c/a\u003e\n### How can I change the output format?\n\nUsing the `-f template` flag you can pass in a\n[golang text template](https://golang.org/pkg/text/template/) to format the output.\n\nOne can use `printf \"%q\" VALUE` to safely quote a value.\n\nThe default template is compatible with [gometalinter](https://github.com/alecthomas/gometalinter)\n```\n{{ .Filename }}:{{ .Line }}:{{ .Column }}:corrected {{ printf \"%q\" .Original }} to \"{{ printf \"%q\" .Corrected }}\"\n```\n\nTo just print probable misspellings:\n\n```\n-f '{{ .Original }}'\n```\n\n\u003ca name=\"problem\"\u003e\u003c/a\u003e\n### What problem does this solve?\n\nThis corrects commonly misspelled English words in computer source\ncode, and other text-based formats (`.txt`, `.md`, etc).\n\nIt is designed to run quickly so it can be\nused as a [pre-commit hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks)\nwith minimal burden on the developer.\n\nIt does not work with binary formats (e.g. Word, etc).\n\nIt is not a complete spell-checking program nor a grammar checker.\n\n\u003ca name=\"others\"\u003e\u003c/a\u003e\n### What are other misspelling correctors and what's wrong with them?\n\nSome other misspelling correctors:\n\n* https://github.com/vlajos/misspell_fixer\n* https://github.com/lyda/misspell-check\n* https://github.com/lucasdemarchi/codespell\n\nThey all work but had problems that prevented me from using them at scale:\n\n* slow, all of the above check one misspelling at a time (i.e. linear) using regexps\n* not MIT/Apache2 licensed (or equivalent)\n* have dependencies that don't work for me (python3, bash, linux sed, etc)\n* don't understand American vs. British English and sometimes makes unwelcome \"corrections\"\n\nThat said, they might be perfect for you and many have more features\nthan this project!\n\n\u003ca name=\"performance\"\u003e\u003c/a\u003e\n### How fast is it?\n\nMisspell is easily 100x to 1000x faster than other spelling correctors.  You\nshould be able to check and correct 1000 files in under 250ms.\n\nThis uses the mighty power of golang's\n[strings.Replacer](https://golang.org/pkg/strings/#Replacer) which is\na implementation or variation of the\n[Aho–Corasick algorithm](https://en.wikipedia.org/wiki/Aho–Corasick_algorithm).\nThis makes multiple substring matches *simultaneously*.\n\nIn addition this uses multiple CPU cores to work on multiple files.\n\n\u003ca name=\"issues\"\u003e\u003c/a\u003e\n### What problems does it have?\n\nUnlike the other projects, this doesn't know what a \"word\" is.  There may be\nmore false positives and false negatives due to this.  On the other hand, it\nsometimes catches things others don't.\n\nEither way, please file bugs and we'll fix them!\n\nSince it operates in parallel to make corrections, it can be non-obvious to\ndetermine exactly what word was corrected.\n\n\u003ca name=\"debug\"\u003e\u003c/a\u003e\n### It's making mistakes.  How can I debug?\n\nRun using `-debug` flag on the file you want.  It should then print what word\nit is trying to correct.  Then [file a\nbug](https://github.com/client9/misspell/issues) describing the problem.\nThanks!\n\n\u003ca name=\"missing\"\u003e\u003c/a\u003e\n### Why is it making mistakes or missing items in golang files?\n\nThe matching function is *case-sensitive*, so variable names that are multiple\nworlds either in all-upper or all-lower case sometimes can cause false\npositives.  For instance a variable named `bodyreader` could trigger a false\npositive since `yrea` is in the middle that could be corrected to `year`.\nOther problems happen if the variable name uses a English contraction that\nshould use an apostrophe.  The best way of fixing this is to use the\n[Effective Go naming\nconventions](https://golang.org/doc/effective_go.html#mixed-caps) and use\n[camelCase](https://en.wikipedia.org/wiki/CamelCase) for variable names.  You\ncan check your code using [golint](https://github.com/golang/lint)\n\n\u003ca name=\"license\"\u003e\u003c/a\u003e\n### What license is this?\n\nThe main code is [MIT](https://github.com/client9/misspell/blob/master/LICENSE).\n\nMisspell also makes uses of the Golang standard library and contains a modified version of Golang's [strings.Replacer](https://golang.org/pkg/strings/#Replacer)\nwhich are covered under a [BSD License](https://github.com/golang/go/blob/master/LICENSE).  Type `misspell -legal` for more details or see [legal.go](https://github.com/client9/misspell/blob/master/legal.go)\n\n\u003ca name=\"words\"\u003e\u003c/a\u003e\n### Where do the word lists come from?\n\nIt started with a word list from\n[Wikipedia](https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines).\nUnfortunately, this list had to be highly edited as many of the words are\nobsolete or based from mistakes on mechanical typewriters (I'm guessing).\n\nAdditional words were added based on actually mistakes seen in\nthe wild (meaning self-generated).\n\nVariations of UK and US spellings are based on many sources including:\n\n* http://www.tysto.com/uk-us-spelling-list.html (with heavy editing, many are incorrect)\n* http://www.oxforddictionaries.com/us/words/american-and-british-spelling-american (excellent site but incomplete)\n* Diffing US and UK [scowl dictionaries](http://wordlist.aspell.net)\n\nAmerican English is more accepting of spelling variations than is British\nEnglish, so \"what is American or not\" is subject to opinion.  Corrections and help welcome.\n\n\u003ca name=\"otherideas\"\u003e\u003c/a\u003e\n### What are some other enhancements that could be done?\n\nHere's some ideas for enhancements:\n\n*Capitalization of proper nouns* could be done (e.g. weekday and month names, country names, language names)\n\n*Opinionated US spellings*   US English has a number of words with alternate\nspellings.  Think [adviser vs.\nadvisor](http://grammarist.com/spelling/adviser-advisor/).  While \"advisor\" is not wrong, the opinionated US\nlocale would correct \"advisor\" to \"adviser\".\n\n*Versioning*  Some type of versioning is needed so reporting mistakes and errors is easier.\n\n*Feedback*  Mistakes would be sent to some server for agregation and feedback review.\n\n*Contractions and Apostrophes* This would optionally correct \"isnt\" to\n\"isn't\", etc.\n","funding_links":[],"categories":["Misc","开源类库","Go","Linters","Other","Programming Languages"],"sub_categories":["未归类","Style and Patterns Checking"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclient9%2Fmisspell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclient9%2Fmisspell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclient9%2Fmisspell/lists"}