Automatic spelling corrections on Github
English has never been one of my strong points (as is fairly obvious by reading my blog), so my latest side project might surprise you a bit. Inspired by the results of tarsnap’s bug bounty and the first pull request received for a new project(slashem - a type safe rogue like DSL for querying solr in scala) I decided to write a bot for github to fix spelling mistakes.
The code its self is very simple (albeit not very good, it was written after I got back from clubbing @ JWZ’s club [DNA lounge]). There is something about a lack of sleep which makes perl code and regexs seem like a good idea. If despite the previous warnings you still want to look at the code https://github.com/holdenk/holdensmagicalunicorn is the place to go. It works by doing a github search for all the README files in markdown format and then running a limited spell checker on them. Documents with a known misspelled word are flagged and output to a file. Thanks to the wonderful github api the next steps is are easy. It forks the repo and clones it locally, performs the spelling correction, commits, pushes and submits a pull request.
The spelling correction is based on Pod::Spell::CommonMistakes, it works using a very restricted set of misspelled words to corrections.
Writing a “future directions” sections always seems like such a cliche, but here it is anyways. The code as it stands is really simple. For example it only handles one repo of a given name, and the dictionary is small, etc. The next version should probably also try and only submit corrections against the conical repo. Some future plans extending the dictionary. In the longer term I think it would be awesome to attempt detect really simple bugs in actual code (things like memcpy(dest,0,0)).
You can follow the bot on twitter holdensunicorn .
Comments, suggestions, and patches always appreciated. - holdenkarau (although I’m going to be AFK at burning man for awhile, you can find me @ 6:30 & D)
Comments
googled a bit arround, and found this post - before that i wasn't sure if that was a bot or some english teacher gone mad..
thanks for the patches your tool created!
https://github.com/Miserlou/WhitespaceBot
Great minds? :)
https://github.com/Miserlou/WhitespaceBot
Great minds? :)
"The code its self is very simple..."
What would your automatic spelling correction bot fix in this sentence fragment?
It would be cool to run llvm clang over all C/Obj-C/C++ projects and use its diagnostic abilities to generate a patch that applies "fix-it hints". See http://clang.llvm.org/diagnostics.html
...What's augument?
Let's fix all those nasty misspellings! ;)
Have a great day
Tom
That's really rather ionic!
It's reported to successfully work on large projects like the Linux kernel, FreeBSD, oFono, ConnMan etc. It uses its own database for common misspelled words (based on the one found on wikipedia). The first time it was used for the Linux Kernel, it generated a patch of thousands of lines, which was accepted by Linus.
I wonder if you could use it to correct also the source code in github projects instead of only the README files. Here it is:
https://github.com/lucasdemarchi/codespell
oh the irony....
also how would I run it and point it at my github repos?
You could block the bot on GitHub if you didn't wish to receive any more pull requests from it, but I'm not convinced that GitHub would agree that it's spam.