CS320, Fall 2006

Please upload your files to CSNS. The files should include all the source code, documentation, and an HTML file midterm.html which contains a link to your JSP page on the CS3 server. Note that file uploading will be disabled automatically after 8:40PM, and late submission will not be accepted.

[Problem Description]

In this exam you are going to implement a web application that translate English words into Spanish. In particular, the application reads an English-Spanish Dictionary File (downloaded from The Internet Dictionary Project) from disk, stores the data in a Java bean, and uses a JSP to take user input and to display the output.

Your application should consist of a JSP page Translator.jsp and a Java bean Translator.java. You may use more JSP pages or Java classes if necessary, but note that no scripting elements or JavaScript is allowed in the JSP page(s).

The dictionary file is also available on the CS3 server under the /tmp directory so you don't have to copy it there. Each line in the file is either a comment line which starts with an #, or a dictionary entry which consists of an English word and its Spanish translation separated by a tab. Note that some words have multiple translations.


When Translator.jsp is requested without any parameters, it displays an input form asking for the word to be translated, as shown below:

Please enter an English word:    

After the user enters a word and clicks the Translate button, Translator.jsp displays the Spanish translation(s) of the word, as well as a link that takes the user back to the input form. For example, if the given word is "language", the following should be displayed:

English: language
  1. la lengua
  2. el idioma[Noun]
  3. el lenguaje[Noun]
Translate Another Word

If no translation is found for a given word, Translator.jsp displays a list of words that are similar to the given word, and the user may click on each word to see its translation. For example, if the user enters the word "helo", the following should be displayed:

No translation was found. Did you mean

The "similarity" between two words can be determined by their Edit Distance, a.k.a. Levenshtein Distance, which is the number of edits (insertion, deletion, or substitution of a letter) it takes to transform one word into the other. For example, the edit distance between "held" and "helo" is 1 because it takes one substitution to transform "helo" into "held".

The list of the similar words should include all the words in the dictionary that is within edit distance of 1 to the given word. And to calculate the edit distance between two words, you may utilize the Java source code available at http://www.merriampark.com/ld.htm.

Finally, if no similar words are found, simply display

No translation was found. Try another word?

where the link will take the user back to the input form.

[Grading Criteria]