A Web-Based Foreign Language Assistant

Flow of Information

Whenever a word in the main text frame is selected, a request for morphological analysis is sent to a CGI script on the server. Three arguments are supplied, in reverse order: the name of the document in the main text frame, an index number of the word to be analysed; and a boolean value, on which more below. The last part of the URL request will appears as follows (example):
    loco2.tcl?true_80_fable
where loco2.tcl is the name of the CGI script. The words in file fable (`Fables de la Fontaine') have been indexed, and the eightieth word has been selected (the word naissiez, see Figure 1).

The result from the server is directed to the frame for morphological output (on the client side). The document provides not only output visible to the user (in this case Analysis: naître+IndI+PL+P2+FinV), but also a JavaScript function call, where the result of the analysis serves as an argument, for instance:

    top.other('na%eetre&FinV')
Only the lemmatization is used, naître FinV (%ee is the URI encoding for î), the derivation of naissiez is not relevant to further processing. Using this argument, the function top.other() then sends two more request to the server, one for dictionary look-up, and one for example look-up, directing the output to the appropriate frames, i.e., the client-side "Dictionary Entry" and "Examples" frames. See Figure 3.

Figure 3: The flow of information between the major components of the Glosser-Web prototype.

No Visible Morphological Output

Even if the frame for morphological output has been deactivated by the user, morphological analysis still has to be performed before dictionary look-up or example look-up can be initiated. Whenever a user requests information about a word, the following JavaScript function is called:
    function display (i) {
	if (useLoco)
	    loco.location.replace ("/glosser_bin/loco2.tcl?true_"
                + i + "_" + file);
	else if (useDict)
	    dict.location.replace ("/glosser_bin/loco2.tcl?false_"
                + i + "_" + file);
	else if (useExp)
	    exp.location.replace ("/glosser_bin/loco2.tcl?false_"
                + i + "_" + file);
    }
The boolean variables useLoco, useDict, and useExp reflect whether or not visible output is desired for morphological analysis, dictionary look-up, and example look-up, respectively. If, for instance, useLoco is false and useDict is true, the first argument to the CGI request is false, and the output is directed to the dictionary frame, instead of the morphology frame. The false argument tells the CGI script not to produce any visible output. The script does return a HTML document, including the call to the JavaScript function top.other(), but with an empty body. So, all the user sees is the dictionary frame going temporarily blank, before the result of dictionary look-up appears.

If both useLoco and useDict are false but useExp is true, then the example frame is used to temporarily hold the invisible output of the morphological analysis.

State and History

All JavaScript code used in Glosser-Web assumes the Glosser-Web frameset is the top frameset. To make sure this is true, the following code is used in the frameset:
    var GlosserTwo = true;
    if (!top.GlosserTwo)
        setTimeout("top.location=location",2000);
First, a boolean variable is set to true in the current document, then its presence is tested in the top document. If it isn't there, the location at the top is set to the location of the Glosser-Web frameset. A time-out of two seconds is used, allowing the user later to back-out to previous web locations, without getting stuck at the current location.

The frameset contains all JavaScript functions, and defines four more variables. However, these variables are never set from within this frameset or its functions. The variables are used to hold the following information: the name of the document in the main text frame, and three booleans that indicated whether the frames for morphological analysis, dictionary look-up, and example look-up are activated. All variables are set by documents being loaded into these frames. For instance, if morphological output is requested by the user, any document appearing in the frame for morphological output has this JavaScript statement:

    top.useLoco=true
The reason for this is as follows: when you first enter Glosser-Web all variables need to be initialised. If variables were set from within the frameset, all variables would be reset whenever you return to the site from another site, even if you used your browser's Back button. In the current set-up, all variables will be reinitialised to the proper values reflecting the current content of the frames.

Results of analysis are not directed to a frame by setting that frame's location, but by using the JavaScript function location.replace(). This means that analyses are not entered into the browser's history list. The user can click the browser's Back button to back-out of the current Glosser-Web main text frame, without first having to go through all the results of previous analyses.