Wintertree Software Inc.

Spellchecker Engines

Home Site index Contact us Catalog Shopping Cart Products Support Search

You are here: Home > Add a spell checker to your applications > ASP/ASP.NET applications


Add a spellchecker to your Active Server Pages (ASP) and ASP.NET applications with Wintertree Spelling Server

This document describes some of the possible approaches for server-based spellchecking using Wintertree Spelling Server.

Wintertree Spelling Server provides everything you need to add a full spellcheck capability to your ASP or .NET applications running on IIS. Click here to find out more about Wintertree Spelling Server. Wintertree Spelling Server includes examples which demonstrate the various user interaction approaches discussed here.

Contents:

User interaction approaches

An ASP or .NET spellchecker is not as easy to implement as a spelling checker in, for example, a desktop application. A Web application that's accessible to the general Internet community may be run on a wide variety of computer systems, browsers, and browser versions, each with different levels of capability and each with its own idiosyncrasies. Spelling checkers need access to dictionaries, which are typically large files. If the spelling checker runs on the client, some means of accessing the dictionaries from the client is needed. Accessing or downloading the files through a slow network connection may result in user frustration. If the files are located on the client system, browsers may prevent a client-based spelling checker from accessing them for security reasons. Running the spellchecker on the server solves these problems, but the problem of how the user communicates with the spelling checker to dispose of spelling problems remains.

The examples included with Wintertree Spelling Server demonstrate four approaches for user interaction with a spelling checker in a Web application:

  1. Via form submission and response

  2. Via form validation
  3. Via a spelling applet
  4. Via an independent form.

Each approach is described here so you can select the one that best suits the needs of your application and its users. Examples demonstrating each approach are included with Wintertree Spelling Server.

Form submission and response

In the form submission and response approach, the text to be spell-checked is entered in an ASP or .NET form and the entire form is submitted to the server, where a script on the server checks the spelling of the text and returns a response. The returned response replaces the original form. If a misspelled word is detected, the returned response is another form that presents the misspelled word and gives the user options for disposing of the problem. Disposing of the problem causes the second form (the spellchecker form) to be submitted to the server, which resumes the search for misspelled words and will cause the spell checking form to be returned again if other misspelled words are detected. One round trip between client and server is required for each spelling error.

Example 2 demonstrates this approach. Each example presents misspelled words to the user in a separate form. The form contains buttons that allow the user to dispose of each spelling error: Ignore, Ignore All, Change, Change All, and Add. Pressing any of these buttons causes the form to be submitted back to the server, where the action implied by the button is carried out.

Although the original form is submitted to the server so its text can be spell-checked, the submission is not necessarily final, meaning the user may not be finished with the form. It's possible to define a special "Check Spelling" button that submits the form to the server solely for the purpose of checking the spelling of the form's text. Because the spellchecker resides on the server, some means of getting the form to the server is necessary to check the spelling, and form submission is a convenient mechanism.

Form validation

Spellchecking can be viewed as a kind of validation that takes place when the form is submitted. During submission, information on the form is checked to ensure required fields were completed, that information entered is syntactically and semantically correct, that information is consistent, etc. A spelling check can be included as part of the validation process, so misspelled words are reported to the user in the same way that, for example, missing information is reported.

This approach is demonstrated in Examples 1 and 4. Example 1 simply lists misspelled words and suggested replacements in a pop-up window. Once spelling errors are reported this way, it is the user's responsibility to correct the errors by manually editing the text.

Example 4 presents a form to collect information from the user. When the form is submitted, the user's responses are validated. This includes ensuring the user has entered all required information, that the information entered by the user is consistent, and that textual input by the user contains no spelling errors. If the form contains no errors it is accepted and no further processing takes place. If the form contains errors (including spelling errors), the form is returned to the user with annotations explaining why the form was not accepted, with the expectation that the user will correct the errors and resubmit the form. In the case of spelling errors, the annotations include buttons that allow the user to correct or ignore the errors. The user resubmits the form after correcting the validation errors, and the process begins again.

When the spelling check occurs during form validation, the form is sent to the server during submission, and is returned to the client only if validation errors are detected.

Spelling Applet

An applet is a small application that is run by the browser on the client system. The applet is downloaded from the server by the browser like any other Web-page content. See Example 5 for a demonstration.

In the Applet approach, text on a form to be spellchecked is submitted to the applet, which communicates with the server to check the spelling of the text. The server returns a list of spelling errors to the applet. Information about misspelled words is presented to the user by the applet. The applet contains buttons that allow the user to dispose of the spelling problem: Ignore, Ignore All, Change, Change All, and Add. The applet carries out the action implied by the button. The applet communicates with the server once per spelling request. When the spellcheck is complete, the corrected text is placed back into the form. JavaScript code running on the client copies text from text areas in the form to the applet, and copies corrected text from the applet back to the text areas.

Independent Form

In the independent form approach, text to be spell-checked is submitted to a script on the server. The script can be self-contained and independent of other ASP or ASP.NET applications. The independent script returns a form that the user interacts with to dispose of spelling errors. The form is displayed in a separate window on the client, so the original form and the spelling form are both open at the same time. When the spelling check is complete, the corrected text is placed back into the original form.

Example 3 demonstrates the independent form approach. When the Check Spelling button is pressed, the form is submitted to a special spellchecker script running on the server. The spellchecker script is independent from the application's scripts, and can be in a different virtual directory. The purpose of submission is simply to make the form's contents accessible to the spellchecker script on the server. At the time the form is submitted, a new window is created on the client and the response from the spellchecker script is directed to the new window.

The spellchecker script returns a form that allows the user to dispose of spelling errors. Buttons and other controls on the form are executed on the client via JavaScript code. Once the spelling form has been generated by the spellchecker script, no further interaction with the server is required (until the next spelling check is requested).

The independent form approach is similar to the applet approach. You can think of the spelling form generated by the spelling script as an applet implemented in JavaScript.

Integrating the user interaction approaches into an ASP application

ASP Example 1 (Form validation)

User interaction:

A blank copy of the form is returned to the client when Example 1's default.asp script is first invoked. When the Check Spelling button is pressed, a new window pops up, showing misspelled words in the text area along with suggested replacements. The user must correct any misspellings manually.

Major components:

Integration steps:

The form contains a single text area named textArea1, and this text area is the one checked when the "Check Spelling" button is pressed.

Create a form similar to the one displayed by default.asp. Define a "Check Spelling" button, and set its ONCLICK handler to "onCheckSpellingBtn(0)". Set the ONCLICK handler for the "Submit" button to "onSubmitBtn(0)". Include a reference to SubmissionScript.js in the document's head.

In CheckSpelling.asp, search for all occurrences of "textArea1" and replace with the name of your text area.

ASP Examples 2 and 3 (Form submission and response)

Examples 2 and 3 show how to interact with the user via HTML forms to dispose of spelling errors. The two examples operate identically, except Example 2 uses Session variables to store state information while Example 3 uses no session variables (state information is stored in hidden fields).

User interaction:

A blank copy of the entry form (the form containing the text areas which will be spell-checked) is returned to the client when the default.asp script is first invoked. The entry form contains text areas; each text area has an associated button labeled "Check Spelling." When the user clicks the "Check Spelling" button, the form is submitted to the server.

If the text area associated with the "Check Spelling" button contains a spelling error, the spelling form is returned to the client. The spelling form shows the misspelled word and contains buttons that allow the user to dispose of the misspelled word: Ignore, Ignore All, Change, Change All, and Add. Clicking any of these buttons resubmits the spelling form. If the text contains other spelling errors, the spelling form is again returned to the client and the process continues. If no further spelling errors are detected, the spelling-complete form is returned to the client. If the user clicks the "Edit Text" button, the entry form is returned to the client.

The entry form also contains a "Spelling Options" button that causes the options form to be returned to the client. Clicking the OK or Cancel buttons in the options form causes the entry form to be returned.

Major Components:

The user interface in each example consists of four forms (the file name in parentheses is the name of the default template file used to construct the form):

Integration steps:

Create an HTML template file for your application's form. In the template file, define text areas for each field you want to spell-check. Set the value of each text area (including text areas you want to spell-check and those you do not) to

!!Request.xxx!!

where xxx is the name of the text area. For example, if you have a text area named "subject", set its value to

!!Request.subject!!

Create a "Check Spelling" submit-type button named "action" for each text area. Create a hidden field named WSSCheckFieldName. Assign the ONCLICK attribute for each "Check Spelling" button to set WSSCheckFieldName.value to the name of the associated text area (in other words, the name of the text area which will be spell-checked when the button is clicked). For example, a "Check Spelling" button for a text area named "subject" would be defined like this:

<INPUT TYPE=SUBMIT NAME="action"
VALUE="Check Spelling"
ONCLICK="WSSCheckFieldName.value='subject'">

Create other template files (spelling form, options form, and spelling-complete form) from the template files provided with the example. Edit each template file and locate the definitions of hidden fields named "textArea1" and "textArea2". Replace these hidden fields with hidden fields for field in your application's form. Assign each hidden field the same name as the corresponding text area from your application's form, and set the hidden field's value to:

!!Request.xxx!!

where xxx is the name of the text area. For example, if your application contains text areas named "subject" and "message", define the following hidden fields:

<INPUT TYPE=HIDDEN NAME="subject" VALUE="!!Request.subject!!">
<INPUT TYPE=HIDDEN NAME="message" VALUE="!!Request.message!!">

All buttons in the form templates that require an action on the server have the same name ("action") and result in the form being posted to the default.asp script on the server. The default.asp script looks at the "action" button's value (i.e., its label) to determine which button was pressed and therefore which action to perform. Note that each button must have a different label for this to work.

Because template files determine the appearance of the forms returned by the examples, you can change the appearance by editing the templates. Be careful when changing any HTML elements in the template files, as most elements are required for proper operation. The purpose of the important HTML elements in the template files is described below.

Note that all of the examples check the contents of a single text area in response to a Check Spelling button press. Checking multiple text areas in a single operation is possible, but would involve keeping track of the current field being spell-checked and advancing to the next field when checking the current field was complete. The Spelling Applet and Example 4 can check multiple text areas in a single operation.

ASP Example 4 (Independent form)

Example 4 uses a pop-up form to interact with the user to dispose of spelling errors. Here are the key features of Example 4:

User interaction:

When the "Check Spelling" button is pressed, a small pop-up window is opened on the client. The window contains the spelling form, populated with information about the first spelling error. The form contains a number of buttons that the user can click to dispose of the spelling error. Disposing of a spelling error causes the next misspelled word to be presented; if all misspelled words have been presented, then the window closes and the corrected text is copied into the original text area in the main form.

Major components:

The following forms are used in Example 4:

The following client-side JavaScript script files are used in Example 4:

Integration steps:

To integrate the Example 4 approach with your application, perform the following steps:

  1. Insert the following tag in the <HEAD> section of your form:

    <SCRIPT LANGUAGE="JavaScript1.1" SRC="SubmissionScript.js">
    </SCRIPT>
  2. Add the following hidden fields to your form:

    <INPUT TYPE=HIDDEN NAME="WSSFieldList" VALUE="TextBox1,TextBox2">
    <INPUT TYPE=HIDDEN NAME="WSSOptions">
    <INPUT TYPE=HIDDEN NAME="WSSLanguage" VALUE="24941">
    <INPUT TYPE=HIDDEN NAME="WSSUserDictionary" VALUE="">
  3. Set the value of the WSSFieldList hidden field to a comma-separated list of text areas you want to spell-check. For example, if you want to check just one text area named MessageBody, set WSSFieldList like this:

    <INPUT TYPE=HIDDEN NAME="WSSFieldList"
    VALUE="MessageBody">

    If you want to check three text areas named Response, Report, and Comments, set WSSFieldList like this:

    <INPUT TYPE=HIDDEN NAME="WSSFieldList" VALUE="Response,Report,Comments">
  4. If you want the spellcheck.asp script to reside in a different virtual directory than your ASP application, locate the following statement in the onCheckSpellingBtn JavaScript function in SubmissionScript.js and replace "spellcheck.asp" with the URL of spellcheck.asp on your server:

document.forms[formNum].action = "spellcheck.asp";

ASP Example 5 (Form validation)

Example 5 demonstrates spell checking during form validation. When the form is submitted, its contents are checked for completeness, syntax, semantics, and spelling. If the form contains errors, it is returned to the client with annotations indicating the type of error. The submitted form is accepted only if it contains no errors.

User interaction:

When the URL for the application's default.asp script is invoked, a blank survey form is returned. When the user submits the survey form, fields on the form are checked for validity. Free-form text fields are checked for spelling errors. If the form contains any validation errors, or the free-form text fields contain spelling errors, the form is returned to the client with annotations indicating the types of errors detected. In the case of spelling errors, the form contains a small box for each spelling error detected. The box contains Ignore and Change buttons, which allow the user to dispose of the spelling error by ignoring (skipping) it or replacing it with a correction. When a spelling error is corrected, the field containing the misspelled word is updated. Once the user has corrected any problems detected in the form, the form is re-submitted and validated again. If the form contains no errors (including spelling errors), the submission is accepted.

Major components:

Example 5 uses a single form (a survey form) contained in default.asp. When spelling errors are detected, the form is populated with information about each spelling error and controls that allow the user to dispose of spelling errors.

In addition, Example 5 uses SpellCheckScript.js, a client-side file containing JavaScript functions that respond to controls used to dispose of spelling errors.

Integration steps

To use the Example 5 approach in your application, perform the following steps:

  1. Insert the following tag into the <HEAD> section of your form:

    <SCRIPT LANGUAGE="JavaScript1.1" SRC="SpellCheckScript.js">
  2. Copy the CheckSpelling VBScript function from Example 5's default.asp script to your form's ASP script.

  3. Define a hidden field in your form for each text area that will be spell-checked. Construct the name of the hidden field by concatenating "IgnoreList" onto the text area's name, and prefixing "WSS" onto the result. For example, if the text area's name is Message, the hidden field used to hold ignored words would be named WSSMessageIgnoreList. Set the VALUE tag of the hidden field to the value of the field from the request (the goal is to transfer the contents of the hidden field from submission to response). You could define this hidden field like this:

    <INPUT TYPE=HIDDEN
    NAME="WSSMessageIgnoreList"
    VALUE="<% =Request.Form("WSSMessageIgnoreList")%>">
  4. During validation, call the CheckSpelling function and pass the name of the text area containing the text to be checked. If your form contains multiple text areas, call CheckSpelling once for each text area. If the text area contains spelling errors, CheckSpelling will return a string containing HTML code that describes each error. You can insert this HTML into the response returned to the client by your ASP script like this:

    <%
    s = CheckSpelling("Message")
    If (s <> "") Then
    Response.Write(s)
    End If
    %>

    If the text area contains no spelling errors, CheckSpelling will return an empty string.

The CheckSpelling function returns spelling errors in a table. One row is created in the table for each spelling error. You can use an alternate presentation by changing the code in CheckSpelling.

ASP Example 6 (Applet)

Example 6 demonstrates use of Wintertree Spelling Server with a Java applet.

User interaction:

When the user clicks a "Check Spelling" button on a form, text in one or more text areas is checked for spelling errors. If an error is detected, a small dialog box pops up with information about the first spelling error. The dialog box contains buttons that allow the user to dispose of the spelling error: Ignore, Ignore All, Change, Change All, and Add. When the user disposes of the current error, the next error is presented. When all spelling errors have been disposed of, text in the form's text area is replaced with corrected text.

Major components:

Integration steps:

Include the following <SCRIPT> tag in the form's head:

<SCRIPT LANGUAGE="JavaScript" SRC="SpellingAppletScript.js">
</SCRIPT>

Create a "Check Spelling" button in the form. Set the button's ONCLICK handler to call the onCheckSpelling JavaScript function. Pass a comma-separated list of JavaScript object references for the text areas that should be spell-checked when the button is pressed. For example, to check text areas named "subject" and "message" define the button like this:

<INPUT TYPE=BUTTON NAME="checkSpellingBtn"
VALUE="Check Spelling"
ONCLICK="onCheckSpelling(document.myform.subject,document.myform.message);">

Insert an <APPLET> reference into the form:

<APPLET CODE="SpellingApplet.class"
NAME="SpellingApplet"
ARCHIVE="SpellingApplet.jar"
WIDTH="1" HEIGHT="1">
<PARAM NAME="ServerURL"
VALUE="http://mydomain.com/WSS/asp/example6/AppletServer.asp">
</APPLET>

Set the VALUE part of the ServerURL parameter to the URL of AppletServer.asp on your server.

ASP Example 7 (Validation of search keywords)

Example 7 demonstrates use of Wintertree Spelling Server in validating search keywords entered by a user. Keywords are checked against a dictionary of known keywords, and if any entered keywords are unknown (i.e., are misspelled), an alternate search string containing only known keywords is presented to the user.

User interaction:

The user enters search keywords into a form, then clicks a "Search" button. The form is returned to the user with links for any documents that match the keywords as entered by the user. If any of the keywords were unknown, the returned form is annotated with a link that shows an alternate set of search keywords containing only known keywords, labeled with a message reading "Did you mean...?". If the user clicks the link, the form is submitted again, but this time the alternate set of keywords will be searched for.

In this example, searching is very primitive and is intended only to demonstrate how Wintertree Spelling Server can be used to validate keywords in search engines.

Major components:

Example 7 uses a single form (default.asp) that simulates the main page of a search engine. Search results are displayed in the same form.

Integration steps:

The first step is to determine what set of words will be used to validate keywords. If the text being searched is general-purpose, it might be sufficient to validate keywords against one of the general-purpose English dictionaries included with Wintertree Spelling Server to detect spelling errors. If the text being searched is specialized (e.g., pages from a catalog, or documents specific to a certain subject), then it may be necessary to create a custom dictionary containing valid keywords. This is the approach used in Example 7: A special language id is used which maps to a custom dictionary containing words from the documents in the search space. The language id you use can be associated with any number of dictionary files configured through the "Dictionaries" string value in the registry.

Incorporate the ValidateKeywords function contained in default.asp into your application. The example uses language id 111, which refers to dictionary file keywords.tlx. You may wish to use a different language id, in which case you must also configure that language in the registry . Call the ValidateKeywords function in your application when keywords for searching are submitted by the user. If any of the keywords are unknown, ValidateKeywords returns a string containing an alternate set of keywords, with unknown keywords replaced by the closest matching known keywords. The alternate set of keywords can be presented to the user as a link (as in the example).

Integrating the user interaction approaches into an ASP.NET application

ASP.NET Example 1 (Form validation)

User interaction:

Example 1 contains a simple form with a single text area and a button labeled "Check Spelling."

When the "Check Spelling" button is pressed, two things happen. First, A new window is created on the client. Next, The form is posted back to the server, where words in the text area are checked for spelling errors. Misspelled words and suggested replacements are displayed in the new window. The user must manually correct any misspellings.

Major components:

Integration steps:

MainForm contains a public property named TextToCheck, which returns a string containing the text from the text area to be spell-checked. Modify the TextToCheck property to return the contents of the text area in your application that should be spell-checked.

ASP.NET Example 2 (Form submission and response)

Example 2 shows how to interact with the user via HTML forms to dispose of spelling errors.

Multiple text areas can be checked in a single operation. A round trip is required between client and server for each misspelled word detected.

The user dictionary is accessed as a server-side file. Spelling options and the main dictionary language id are stored in Session variables.

User interaction:

A blank copy of the entry form is returned to the client when application's URL is first invoked. The entry form contains text areas and a button labeled "Check Spelling." When the user clicks the "Check Spelling" button, the form is submitted to the server.

If the text area contains a spelling error, the spelling form is returned to the client. The spelling form shows the misspelled word and contains buttons that allow the user to dispose of the misspelled word: Ignore, Ignore All, Change, Change All, and Add. Clicking any of these buttons resubmits the form. If the text contains other spelling errors, the spelling form is returned to the client and the process continues. If no further spelling errors are detected, the spelling-complete form is returned to the client. If the user clicks the "Edit Text" button, the entry form is returned to the client.

The entry form also contains a "Spelling Options" button that causes the options form to be returned to the client. Clicking the OK or Cancel buttons in the options form causes the entry form to be returned.

Major components:

Integration steps:

MainForm contains a public string array named CheckFieldNames. This array contains the names of fields in MainForm that should be spell-checked when the "Check Spelling" button is clicked. Modify the CheckFieldNames array to contain a list of fields in your application's form.

Before transferring to other forms, save the contents of each field in your application's form in Session variables with the same name of the field. For example, if your application contains a field named "subject", save its contents in Session["subject"] (C#) or Session("subject") (VB).

ASP.NET Example 3 (Independent form)

Example 3 uses a pop-up form to interact with the user to dispose of spelling errors. Client-side JavaScript code embedded in the pop-up form responds to button presses.

Multiple text areas can be checked in a single operation, and the spelling results for all text areas are returned in a single round trip to the server.

The user dictionary and spelling options are stored on the client system in a browser cookie.

User interaction:

When the "Check Spelling" button is pressed, a small pop-up window is opened on the client. The window contains the spelling form, populated with information about the first spelling error. The form contains a number of buttons that the user can click to dispose of the spelling error. Disposing of a spelling error causes the next misspelled word to be presented; if all misspelled words have been presented, then the window closes and the corrected text is copied into the original text area in the main form.

Major components:

Integration steps:

Insert a reference to SubmissionScript.js in the <HEAD> section of your form:

<script language="javascript" src="SubmissionScript.js"></script>

MainForm contains one or more text areas which will be spell-checked and buttons labeled "Check Spelling" and "Submit." Assign the "Check Spelling" button's "onclick" attribute to call the onCheckSpellingBtn JavaScript function, and assign the "Submit" button's "onclick" attribute to call the onSubmitBtn JavaScript function.

MainForm implements an interface named SpellCheckField. The SpellCheckField interface specifies the following public properties:

Base your application's main entry form on the SpellCheckField interface, and define the properties required by this interface.

ASP.NET Example 4 (Form validation)

Example 4 demonstrates spell checking as part of form validation. When the form is submitted, fields on the form are validated for completeness and correctness. As part of the validation, text-containing fields on the form are checked for spelling errors. If the fields contain spelling errors, the form is returned with controls which describe the misspelled word found and provide a means for the user to dispose of (ignore or change) the misspelled words.

User interaction:

When the user submits the survey form, fields on the form are checked for validity. Free-form text fields are checked for spelling errors. If the form contains any validation errors, or the free-form text fields contain spelling errors, the form is returned to the client with annotations indicating the types of errors detected. In the case of spelling errors, the form contains a small box for each spelling error detected. The box contains Ignore and Change buttons, which allow the user to dispose of the spelling error by ignoring (skipping) it or replacing it with a correction. When a spelling error is corrected, the field containing the misspelled word is updated. Once the user has corrected any problems detected in the form, the form is re-submitted and validated again. If the form contains no errors (including spelling errors), the submission is accepted.

The user must explicitly indicate that any reported words are correct by clicking the Ignore button associated with the word. Any misspelled words not ignored or corrected will be reported again when the form is re-submitted.

Major components:

Integration steps:

To use the Example 4 approach in your application, perform the following steps:

  1. Insert the following tag into the <HEAD> section of your form:

    <SCRIPT LANGUAGE="JavaScript1.1" SRC="SpellCheckScript.js">
  2. Insert a custom validator in your form for each text area you want to spell-check.

  3. Define a hidden field in your form for each text area that will be spell-checked. Construct the name of the hidden field by concatenating "IgnoreList" onto the text area's name, and prefixing "WSS" onto the result. For example, if the text area's name is Message, the hidden field used to hold ignored words would be named WSSMessageIgnoreList.

  4. Copy the CheckSpelling method from Example 4's MainForm.aspx.cs or MainForm.aspx.vb source file to your form's source file. The CheckSpelling method returns spelling errors in a table. One row is created in the table for each spelling error. You can use an alternate presentation by changing the code in CheckSpelling.

  5. In the ServerValidate handler for your text-area validators, call the CheckSpelling method and pass the name of the text area containing the text to be checked. If the text area contains spelling errors, CheckSpelling will return a string containing HTML code that describes each error; otherwise, CheckSpelling will return an empty string. Set the handler's ServerValidateEventArgs.isValid property to true if the string is empty, and false otherwise. Set the validator's ErrorMessage property to the string returned by the CheckSpelling method.

ASP.NET Example 5 (Applet)

Example 5 demonstrates interacting with the user to dispose of spelling errors via a Java applet.

The user dictionary and spelling options are stored in a browser cookie.

User interaction:

When the user clicks a "Check Spelling" button on a form, text in one or more text areas is checked for spelling errors. If an error is detected, a small dialog box pops up with information about the first spelling error. The dialog box contains buttons that allow the user to dispose of the spelling error: Ignore, Ignore All, Change, Change All, and Add. When the user disposes of the current error, the next error is presented. When all spelling errors have been disposed of, text in the form's text area is replaced with corrected text.

Major components:

Integration steps:

Include the following <SCRIPT> tag in the form's head:

<SCRIPT LANGUAGE="JavaScript" SRC="SpellingAppletScript.js">
</SCRIPT>

Create a "Check Spelling" button in the form. Set the button's ONCLICK handler to call the onCheckSpelling JavaScript function. Pass a comma-separated list of JavaScript object references for the text areas that should be spell-checked when the button is pressed. For example, to check text areas named "subject" and "message" define the button like this:

<INPUT TYPE=BUTTON NAME="checkSpellingBtn"
VALUE="Check Spelling"
ONCLICK="onCheckSpelling(document.myform.subject,document.myform.message);">

Insert an <APPLET> reference into the form:

<APPLET CODE="SpellingApplet.class"
NAME="SpellingApplet"
ARCHIVE="SpellingApplet.jar"
WIDTH="1" HEIGHT="1">
<PARAM NAME="ServerURL"
VALUE="http://mydomain.com/WSS/asp/example6/AppletServer.asp">
</APPLET><

Set the VALUE part of the ServerURL parameter to the URL of AppletServer.asp on your server.

ASP.NET Example 6 (Search keyword validation)

Example 6 demonstrates use of Wintertree Spelling Server in validating search keywords entered by a user. Keywords are checked against a dictionary of known keywords, and if any entered keywords are unknown (i.e., are misspelled), an alternate search string containing only known keywords is presented to the user.

User interaction:

The user enters search keywords into a form, then clicks a "Search" button. The form is returned to the user with links for any documents that match the keywords as entered by the user. If any of the keywords were unknown, the returned form is annotated with a link that shows an alternate set of search keywords containing only known keywords, labeled with a message reading "Did you mean...?". If the user clicks the link, the form is submitted again, but this time the alternate set of keywords will be searched for.

In this example, searching is very primitive and is intended only to demonstrate how Wintertree Spelling Server can be used to validate keywords in search engines.

Major components:

Integration steps:

The first step is to determine what set of words will be used to validate keywords. If the text being searched is general-purpose, it might be sufficient to validate keywords against one of the general-purpose English dictionaries included with Wintertree Spelling Server to detect spelling errors. If the text being searched is specialized (e.g., pages from a catalog, or documents specific to a certain subject), then it may be necessary to create a custom dictionary containing valid keywords. This is the approach used in Example 6: A special language id is used which maps to a custom dictionary containing words from the documents in the search space. The language id you use can be associated with any number of dictionary files configured through the "Dictionaries" string value in the registry.

Incorporate the ValidateKeywords method contained in MainForm.aspx.cs (C#) or MainForm.aspx.vb (VB) to your application. The example uses language id 111, which refers to dictionary file keywords.tlx. You may wish to use a different language id, in which case you must also configure that language in the registry. Call the ValidateKeywords function in your application when keywords for searching are submitted by the user. If any of the keywords are unknown, ValidateKeywords returns a string containing an alternate set of keywords, with unknown keywords replaced by the closest matching known keywords. The alternate set of keywords can be presented to the user as a link (as in the example).


Home Site index Contact us Catalog Shopping Cart Products Support Search


Copyright © 2015 Wintertree Software Inc.