"Linux Gazette...making Linux just a little more fun!"

Dict Continued

By Larry Ayers

Last month I wrote about the DICT client-server protocol, a GPL-licensed system for looking up words in a variety of dictionary databases. I received some feedback from Rik Faith, DICT's primary developer, in response to my statements concerning the server's memory usage. Here is a quote from the message:

In your review, you mention that dictd requires a lot of memory to run, and suggest that people may not want to run the service all of the time. First, since dictd memory maps all of the files that it uses, ps may show that it is "using" far more memory than it actually is. I suspect that this may vary between kernel versions and ps, depending on how mmap'd memory is reported. Second, dictd doesn't do anything when it is waiting for a socket connection, so the memory it uses will be swapped out over time. Hence, I think it should be fine to start dictd at boot time and to leave it running -- I do this on my underpowered laptop and it works out ok in the sense that dictd doesn't use any resources when it is not responding to queries. If you happened to notice a situation where a waiting dictd is using cpu time, then that's a bug that I'd like to fix.

Thanks for your review of dict-related software -- I hope we can improve dictd and related tools a great deal over the next 6-12 months.

I was curious about the dictionary index files and just how they had been generated. In response to my query, Faith responded:

We currently write one-off scripts for each input database. These sources are all distributed on the ftp site. We are moving toward a dictionary interchange format (DICF) from which indexes will be automatically generated. But one-off scripts will still be required to convert the databases into DICF format. We expect, however, that a large amount of new material will be written directly in DICF. Our plan was to have DICF ready by 4Q1998, but this schedule may slip.

When I first began to use the DICT system, it occurred to me that an Emacs mode would be useful, so that a keystroke would open up a window showing definitions of the word under the cursor. Some time later I was browsing the gnu.emacs.sources newsgroup and happened to find two independently developed dict.el files, both functional but with slightly different features.

Alexander Vorobiev's version was the first one I tried. It works well under both GNU Emacs and XEmacs. This dict.el doesn't have any mouse bindings included, but does have a feature I appreciate: rather than directly sending the input word to the dictd server, the word first appears in the mini-buffer at the bottom of the screen, allowing it to be edited first. For example, this can useful if you would like the singular rather than the plural form of a word defined, or if the definition of a phrase is sought.

The other dict.el was written by Shenghuo Zhu. This one also will work on both emacsen, but the mouse-binding (button two looks up the word under the cursor) works only with GNU Emacs, though it probably wouldn't be too difficult to adapt it to XEmacs. Syntax-highlighting for GNU Emacs is also included.

Both modes allow a keystroke combination to be set for looking up a word; I've been using Control-c-Enter. Since the two files are small, I've bundled them into one gzipped tar archive and included them with this issue of the Gazette. You can find the file here. Instructions for installation of the modes can be found near the beginning of each file. In the archive you will find that one of the modes has been renamed dict2.el; before using that mode it should have its original name, dict.el, restored.

Dict-mode can even be used as a substitute for the Emacs Ispell spell-check interface. If a misspelled word is passed to the dictd server, a response such as this will be generated:

No definitions found for "arcive", perhaps you mean:
web1913:  Archive  Argive  Arrive
wn:  archive  Argive  arrive
foldoc:  archive

Of course Ispell is more suitable for spell-checking an entire buffer, but if a single word's spelling is doubtful, dict-mode offers an alternate solution.

Last modified: Wed 28 Oct 1998

Copyright © 1998, Larry Ayers
Published in Issue 34 of Linux Gazette, November 1998