December 24, 2010

Glance: Better word lookup

Glance is an offline dictionary lookup utility written with the intent to make looking up words quick, and as intuitive as possible to your work on the computer or internet.

Why

When on Windows, I was a big fan of WordWeb, which is a nifty dictionary utility, that sat in the taskbar, and made it simple to lookup words by selecting, and hitting a keyboard shortcut. The closest equivalent on Ubuntu is gnome-dictionary, but it lacks the ability to lookup selected words. By default it is configured to look things up online, so you were out of a dictionary when not connected. You also can't make anything beyond simple exact-match calls (until you figure out what the heck strategies are, and how to use them).

So I wrote glance to fill my specific needs. They weren't many.

  • Lookup a word by simply selecting it in browser/text-editor/ebook reader and hitting a key (like F7.. who uses that anyway?)
  • Search for prefix/suffixed words with *. Ex: *arch, matri*, *morph*.
  • Provide definition of the word, etymology (along with meaning of the root words), Similar words, usage, etc (These depend on the dictionaries installed)

Setup

These instructions are for Ubuntu (and should work on Debian). Install equivalent packages on other distributions.

First install dependencies, and local dictionary via

apt-get install python-gtk2 xsel
apt-get install dictd dict dict-wn dict-gcide

This installs the Wordnet and the Comprehensive English dictionary. You can also install:

dict-moby-thesaurus - Largest and most comprehensive thesaurus
dict-jargon - Jargon definitions
dict-foldoc - FOLDOC dictionary database
dict-vera - Dictionary of computer related acronyms
dict-bouvier - John Bouvier's Law Dictionary for the USA
dict-devil - A satirical, cynical and irreverent dictionary of common words
dict-gazetteer - Place names, population and location provided by the U.S. Census Bureau

There are multiple language A to B dictionaries available as well. To see all available dictionaries, run:

apt-cache search dict | grep ^dict

glance is a single file utility. Copy the file to /usr/local/bin

sudo cp glance /usr/local/bin

Setup keyboard shortcut F7 (or other), Add a custom shortcut for glance. Do this by running gnome-keyboard-properties.

All done. Select a word and press F7 anytime to view in all it's defined glory.

Where

You can grab the utility from https://bitbucket.org/anilg/misc/src. Click on glance, and grab the raw file.

Screenshot

And we end with an obligatory screenshot.

[caption id="" align="alignnone" width="615" caption="Glance Screenshot"]Glance[/caption]

Simple, no-frills look. Just the way I like it. Hope others out there like it too.

[Update]

So looks like google-fu failed me initially, and I missed out on multiple good dictionary lookup choices, that did many of the things I was looking for. Special mentions goto Artha, Stardict and qstardict. There's things to like about all of these, but my favorite is still Glance (biased much, eh?).

Having used Glance incessantly over the past week, I simply love the no frills look of it. It pops up, and there isnt much to do apart from scrolling up or down. No tabs separating definition, similar words, etc, no menu items. All information is presented upfront.

Also I like to to be dependent on system packages (rather than extracting pre-archived packages ala Stardict, though this makes it hard to port). Glance being tiny does help too.

A couple of updates that I'd like to implement would be syntax highlighting the definition to make it easier on the eyes (patches welcome). Glance will never have any cluster of tabs or menu items or screens. All the information will be presented in the one scrollable page. Another quick feature would be to automatically add a shortcut, and install itself into /usr/local/bin, with a confirmation from the user. Just need to figure out pygtk interface to desktop shortcuts.