google hack for your desktop: keyword correct
March 9th, 2008Do you know the situation where you just aren’t sure whether you are spelling a word the right way? If you know how to type the word pretty well, then a dictionary might work just fine. If you aren’t sure at all you might consider using Google’s ‘Did you mean’-feature. Check out a simple demonstration for the word Wondows, which could mean ‘Windows’. ;-) If you happen to use that google-feature just too many times you might be interested in my small hack:
wget -O google_correct.py http://grml.org/scripts/google_correct.txt
chmod +x google_correct.py
This small python script uses xsel (so it currently works only on systems providing xsel ;-)) to retrieve the currently selected word from your X selection, executes a google search and parses the output for the keyword inside the ‘Did you mean’ section. Finally it sets the corrected keyword as your current X selection. If you provide the keyword directly as an option, then the script just outputs the corrected keyword without touching your X selection so you can integrate it directly inside your $EDITOR as well as an option. This gives you the flexibility to use this feature globally(!) inside your preferred window manager. Select a word, press the keybinding for executing google_correct.py and now you’ve the corrected word available for further actions…
Finally don’t forget to put the affected word (after double-checking it using a real dictionary of course) into your $EDITOR’s dictionary to keep such “help m0m, I can’t sp3ll w0rds anymore” situations at a minimum. I’m using a personal dictionary file and ‘iab wondows windows’ inside Vim to fix spelling errors for words I’m unsure how to spell or which I always get worng.
A whishlist of further ideas/features for the script can be found in the header of the script itself. Further input welcome.








