CGIs in Lisp
Volume Number: 12
Issue Number: 7
Column Tag: Webtech™
A Web dictionary server
By Mathieu Lafourcade and Gilles Sérasset
Note: Source code files accompanying article are located on MacTech CD-ROM orsource code disks.
A paper dictionary is fine for reading comfort, versatility, etc., but updating of the
data is not possible (apart from buying a new dictionary!), and the amount of data may
be smaller than an electronic version. A resident electronic dictionary allows cut and
paste, and updates are generally possible; but, like the paper dictionary, you must
carry it along (in your hard disk). The Web-based dictionary doesn’t take any space
on your hard disk; the memory footprint is that of your Web browser. On the other
hand you do rely on the availability of the network and/or server.
This article describes how a Web server offering multilingual dictionary
services was set up by integrating three components: MacHTTP, AppleScript, and
Macintosh Common Lisp (MCL). The dictionary server is constructed from a
dictionary application, ALEX, written with MCL. This application can be remotely (and
facelessly if needed) controlled with AppleScript. Given this design, the connection
with MacHTTP is painless. The result is a very cost-effective way of providing a large
linguistic resource on the Web.
Our developmental approach was to come up with something functional as fast as
possible and to enhance the solution afterward. We had to compromise between
functionality delivered to the user, performance, and the technical implications for the
developer.
We first describe a typical user session; you can try this out yourself by
pointing to the URL from your own browser (you can see the URL in Figure 1). The
general architecture of the server is then presented, followed by some technical details
about the three components.
Note: The included sources have often been trimmed to keep this article as short
as possible - for instance, the error handling is generally not included.
Figure 1. Initial Web page of the server
A Typical User Session
The Web page displays a form (Figure 1). The user can choose a dictionary, enter a
word to look up, and click on the “Look up” button. It is possible to terminate the
candidate word with an asterisk; in this case the first entry which starts with the text
entered is returned.
A new page appears displaying the information associated with the word entered
(Figure 2). If the entry is not found, a (friendly) error message is given. Beside the
title (corresponding to the word looked up), the user has access to links to the
previous word (if any), to the form (just like pressing the “Back” button of the Web
client), or to the next word (if any). This way, the user can walk through the entire
dictionary.
Figure 2. The data displayed for the entry “apple”;
the source of this page is given in Listing 10
For example, the user can click on the previous entry “applause” and obtain the
corresponding page (Figure 3). The user can continue to scan the dictionary or can
return to the form and choose an other entry or dictionary.
Figure 3. The web page for the entry “applause”
The HTML Form
The form used as an interface between user and server, the starting point of a session,
is a plain HTML page. The link between this page and the application handling the
action is made in the form declaration. The standard POST method is used for sending
the message from the server to the application, wAlex.acgi.
We assume you are familiar with HTML (if not, check out the numerous
informative pages available on the Web). The tag specifies a form, which may
include various items, such as text input (text field) and select input (menu). Notice
that many less common characters (in English at least) are represented a specific way
(for example the “ç” as "ç), and this is the beginning of big problems when
you decide to deal with other languages, like French for instance.
Listing 1:
HTML Source of Figure 1
The dictionary lookup form
All the cosmetic and informative stuff at the beginning of the page.
web-generic-ds
R
src="http://161.142.8.195/wSambre-us/ALEX/Gifs/wAlex-vert.GIF" WIDTH=25> src="http://161.142.8.195/wSambre-us/ALEX/Gifs/wAlexVLogo.GIF"> | GENERICR dictionary web service
| R
The form definition starts here.
R
To look up for a word fill the text field below and click in the button "Submit". You can search by prefixes by adding the character "*" at the end of the entry.R | R
R
| REntry to look up VALUE="" MAXLENGTH=150> in
| R
The Submit button is defined here.
One hidden item giving the name of the form we are in.
The form definition ends here.
Some links to specific dictionary forms are presented here.
R