Overview
I write quite a lot, so I need convenient access to a dictionary. When I am home I have the option of logging on and accessing one of the many online dictionaries, but there are some difficulties with this approach. One, I have slow Internet access, and the Web sites that offer dictionary services tend to load very slowly because of all the advertising they carry. Two, Internet access is sometimes not available to me, for example when I am on the road (or on the water) on my way to one of the rather wild places I visit.
Given these limitations, I have always thought it would be nice to have a free, usable dictionary program/database that would function without requiring Internet access, but until recently I didn't think such a thing existed. But, once again, the Linux/open source community has come through.
I was recently browsing one of the executable directories in my Fedora 4 installation when I noticed a program named "dict". I tried executing it and quickly discovered what it is — a dictionary client program that relies on a server, either local or Internet-based. I decided to explore this program and see if I could make it work without requiring Internet access.
Options
After a few days of experimentation, I have worked out how to use this dictionary service in a number of ways:
- If you always work while connected to the Internet:
- you can use the command-line interface program "dict", which doesn't require much in the way of local resources, and that by default relies on readily available Internet servers that support its protocol.
- You can also use the KDE application "kdict," a modern, X windows GUI application that relies on "dict" behind the scenes.
- You can use my PHP script that basically does what "kdict" does, but has some advantages if you tend to have a browser running while you work, or if you are not running the KDE desktop environment.
- If you want to make "dict" work for you on an intranet, or on a personal system not connected to the Internet:
- You can download the dictionary database files from (example) http://www.gutenberg.org/ebooks/673, set them up on your local system or intranet server, enable a local "dictd" dictionary server, then access the service from your local network using the above-described clients.
So it seems this task is logically divided into two parts — server and client.
As to the server, most recent Linux distributions have the "dictd" server available (Fedora 4 does). In this case it is a simple matter of downloading and installing the databases, editing a couple of configuration files, and starting the server.
As to the client, you have the choice of using the CLI program "dict", or you can use "Kdict" if you prefer a GUI application. I also have written a
PHP page that accesses "dict" and presents its results on a Web browser.
Here are the details:
Server
If you are always connected to the Internet and don't need local/intranet server functionality, you can skip this section.
- Download your choice of, or all of, the dictionary databases located at ftp://ftp.dict.org/pub/dict/pre/ or another location that has these database files.
- Unpack the database files. Each tarball will contain a database file with the suffix ".dict.dz" and a same-name index file with the suffix ".index".
NOTE: One of the databases from the above site has a misnamed file. The "world02" database has a file named "world02.dict" instead of "world02.dict.dz". You have the option of renaming the file or editing the configuration file (explained below) to reflect the default name.
- Place the database files in any convenient location on your system, based on your local needs. Be sure to make the database files readable by anyone, like this:
$ chmod +r *.dict.dz *.index
- Create two configuration files required by "dict" and "dictd". The files are normally located in the /etc directory, and should have content like this:
File
|
Example Contents
|
/etc/dict.conf
|
server localhost
|
/etc/dictd.conf
|
database dbname1 { data "/path/to/dict/files/dbname1.dict.dz"
index "/path/to/dict/files/dbname1.index" }
database dbname2 { data "/path/to/dict/files/dbname2.dict.dz"
index "/path/to/dict/files/dbname2.index" }
database dbname3 { data "/path/to/dict/files/dbname3.dict.dz"
index "/path/to/dict/files/dbname3.index" }
|
Replace the example content above with the path to, and the names of, the database files you have downloaded and installed. Each database you install should have its own entry modeled after the examples shown.
- Enable the dictd server (as root):
# /sbin/service dictd start
# /sbin/chkconfig dictd on
If your Linux distribution doesn't have the "dictd" dictionary server, or if you have not yet installed it, or if there is any problem with file accessibility or configuration, you will know at this point.
- Assuming that everything has worked to this point, you can test the server by running a client and looking up a word.
To initially test your local installation, you may want to disable Internet access, because if the "dict" program experiences any difficulty with local access, it may try to access Internet databases rather than fail with an error message.
If you have any doubt about what "dict" is doing, or how it is processing your request, launch it this way:
$ dict -v myword
The "-v" flag instructs "dict" to verbosely explain its actions.
- One more thing. While researching online about "dictd", the dictionary server, I read that it uses a fair amount of memory, even when idle. So if you have memory problems, try shutting down the "dictd" service and comparing the memory footprint:
# /sbin/service dictd stop
# free
People who actually need dictionary service, and who appreciate the speed of this server's response, probably won't care about the amount of memory used by "dictd", that makes its fast response possible.
Client
This is the easy part. A typical, modern Linux distribution will have a copy of the "dict" CLI client program, and if you are running KDE, you will very likely have the "kdict" GUI application available as well.
You can also write a Web interface for "dict," an approach you might prefer because it allows anyone on your intranet to access the machine that hosts the "dictd" server. I have created a
PHP page for my own use. Here is a sample of the output from the page:
NOTE: The
PHP page was written for intranet use. If you decide to post this page on the Internet and give it access to your Web server's resources, I strongly recommend that you examine its code carefully. I wrote it for local network use, and I haven't given much thought to security issues.
Conclusion
I think of this program (and database) as more proof of the coöperative spirit in the open-source movement, as well as being a useful tool, flexibly configurable in a way that would be difficult or impossible under Microsoft Windows.