A dictionary server written in rust
It's been almost a decade since I last wrote a blog entry! Life has been busy, my children are becoming older, and... here I am, still. My gopher-phlog has been a little more active at gopher://jan.bio.
Anyhow, I completely ignored my previous phlog post about focussing, and got carried away with implementing yet another RFC. This time wrote a simple implementation of RFC2229: A Dictionary Server Protocol.
The standard from 1997 describes a TCP-based protocol for querying dictionaries, like wordnet, The Devils Dictionary, the Jargon dictionary and other freely available dicts.
Before the standard came along, the only available dictionary protocol was the webster protocol, which is restricted to a single dictionary. RFC2229 attempts to fix this and offers access to several dictionaries including a number of strategies for finding words within an index.
Basically, there are two commands available: MATCH and DEFINE.
DEFINE is called with a database (that is, a dictionary) and a word to define. If the word exists in the dictionary, a definition of the word is returned.
This works of course only if the word exists in a dictionary. But how do you look up words in the index? This is where the MATCH command comes into play.
MATCH allows you to looks for words in an index with a certain strategy. A strategy is the algorithm used to query the index. The simplest strategy is "exact", which only matches the exact word. Another strategy is "prefix", which returns a list of words starting with a given prefix. Implementations are free to provide more strategies, like soundex matching or levenshtein, thus providing some kind of spell checking for words.
Besides these commands, the RFC describes commands for listing dictionaries (SHOW DB), getting info about a certain database (SHOW INFO), listing stragegies (SHOW STRAT) and some commands for information about the server, like SHOW STATUS.
I wrote a quick implementation of a server using rust (surprise!) available on github, currently hard-coded to two databases (Jargon random word definition from the dictionary. Yay!
You can play with the server (or any server that implements RFC2229) by telnet'ing to port 2628. Just enter HELP after connecting to show a list over available commands. This is, btw, a nice feature of this protocol: You can use telnet and explore the protocol using the integrated help function.
One important feature missing, is to integrate the dictionary server with gopher. It should be trivial to change the server to return gophermaps instead of ASCII definitions. Pull requests welcome!