Spelling Suggestions for WebVóyage with aspell and Perl

Disclaimer

Code and instructions for implementing aspell Spelling Suggestion features for WebVóyage. Use at your own risk. TCC is not responsible for damage or problems caused by the use of this code. No warranties or guarantees of any kind are implied or assumed.
Version 1.0
Scripts by Jim Robinson
Tarrant County College
828 Harwood Rd.
Hurst, TX 76054-3299
(817) 515-4310
Email
Copyright © 2019, Tarrant County College Distict ("TCCD"). All rights reserved.

For use with the WebVóyage product by Endeavor Systems, Inc. Ex Libris™ LTD.
"Voyager" and "WebVóyage" are trademarks of Endeavor Information Systems, Inc. Ex Libris™ LTD.

SpellCheck.pm copyright
http://www.voltar.org

Purpose: Javascript and Perl scripts use aspell to check a user's spelling when no hits are found in OPAC.

No warranties or guarantees of any kind or implied. use at your own risk. It works for us, so we thought we'd share... ;-)

By using this software the USER indicates that he or she has read, understood and and will comply with the following:

TCCD hereby grants USER permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee, provided that:
  1. the above copyright notice appears in all copies of the software and its documentation, or portions thereof, and
  2. a full copy of this notice is included with the software and its documentation, or portions thereof, and
  3. neither the software nor its documentation, nor portions thereof, is sold for profit. Any commercial sale or license of this software, copies of the software, its associated documentation and/or modifications of either is strictly prohibited without the prior consent of TCCD.
  4. Title to copyright to this software and its associated documentation shall at all times remain with TCC. No right is granted to use in advertising, publicity or otherwise any trademark, service mark, or the name of TCCD.
  5. This software and any associated documentation are provided "as is," and TCCD MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING THOSE OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR THAT USE OF THE SOFTWARE, MODIFICATIONS, OR ASSOCIATED DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER INTELLECTUAL PROPERTY RIGHTS OF A THIRD PARTY. TCCD, Tarrant County College District, its Regents, officers, and employees shall not be liable under any circumstances for any direct, indirect, special, incidental, or consequential damages with respect to any claim by USER or any third party on account of or arising from the use, or inability to use, this software or its associated documentation, even if TCCD has been advised of the possibility of those damages.
This code is meant to be used with the WebVóyage product by Endeavor Systems, Inc. Ex Libris™ LTD.™ When a user search of the library catalog receives no hits, the user's search criteria is sent to aspell. aspell will return a spelling suggestion if the word is misspelled.

The javascripts, perl source, images, and html are enclosed in perl_spellcheck.zip.

You can see these scripts in action at http://library.tccd.edu (PHP version). Enter a mispelled word, such as pikcle or "captian cook".

Requirements:
  • Perl must be installed on the WebVóyage server. (It should be installed by default)
  • Perl modules Carp.pm, IPC::Open2.pm, IPC::Open3.pm must be installed. (These may have been installed by Endeavor.)
  • aspell and a dictionary must be installed and working.
  • The spelling suggestion uses JavaScript. Browsers with JavaScript disabled will not be able to take advantage of this code, but it will not prevent them from using WebVóyage normally.

Instructions

    These instructions assume you have root access to your server and a working compiler for the dictionary.
  1. Log in to your webvoyage server, change to a source directory. I use /opt/sfw/src/. You can use /export/home/voyager if you like.
  2. su root (Use sudo if you have it configured)
  3. Download and install ncurses-5.6 package in /usr/local
    1. curl -O ftp://ftp.sunfreeware.com/pub/freeware/sparc/9/ncurses-5.6-sol9-sparc-local.gz
    2. gunzip ncurses-5.6-sol9-sparc-local.gz
    3. pkgadd -d ncurses-5.6-sol9-sparc-local
  4. Download and install libgcc-3.3 package in /usr/local/lib
    1. curl -O ftp://ftp.sunfreeware.com/pub/freeware/sparc/9/libgcc-3.3-sol9-sparc-local.gz
    2. gunzip libgcc-3.3-sol9-sparc-local.gz
    3. pkgadd -d libgcc-3.3-sol9-sparc-local
  5. Download, compile and install aspell-0.60.2 in /usr/local
    1. curl -O ftp://ftp.sunfreeware.com/pub/freeware/sparc/9/aspell-0.60.2-sol9-sparc-local.gz
    2. gunzip aspell-0.60.2-sol9-sparc-local.gz
    3. pkgadd -d aspell-0.60.2-sol9-sparc-local
  6. Download and install an English dictionary in /usr/local/aspell-0.60
    1. curl -O ftp://ftp.gnu.org/gnu/aspell/dict/en/aspell6-en-6.0-0.tar.bz2
    2. bunzip2 aspell6-en-6.0-0.tar.bz2
    3. tar -xvf aspell6-en-6.0-0.tar
    4. cd aspell6-en-6.0-0
    5. ./configure
    6. make
    7. make install
  7. Test the aspell install.
    1. Create a file with a misspelled word or 2 and call it spelling_error.txt (or use the one in the zip file)
    2. /usr/local/bin/aspell -c spelling_error.txt
    3. Note: you'll have to have apsell working before anything else will work...
  8. Install Perl spellcheck files
    1. In /m1/voyager/xxxdb/webvoyage/cgi-bin/, add the spellcheck folder included in the zip file.
      (Inside the spellcheck folder should be two files, SpellCheck.pm and spell.cgi).
    2. In /m1/voyager/xxxdb/webvoyage/html/js/, add the spell.js file included in the zip file.
      (If you don't have a /m1/voyager/xxxdb/webvoyage/html/js/ directory, make one! mkdir /m1/voyager/xxxdb/webvoyage/html/js
    3. In /m1/voyager/xxxdb/webvoyage/html/images/, add the load.gif file included in the zip file.
  9. Make Perl cgi executable
    1. cd /m1/voyager/xxxdb/webvoyage/cgi-bin/spellcheck
    2. chown voyager:endeavor *
    3. chmod 755 spell.cgi
  10. Tell WebVóyage to check spelling
    1. In /m1/voyager/xxxdb/etc/webvoyage/local/nohitsmsg.htm, add the following lines:
      <img src="/images/load.gif" onload="spellCheck();" >
      Your search resulted in no hits!
      <div name="spellMessage" id="spellMessage">.</div>
    2. In /m1/voyager/xxxdb/etc/webvoyage/local/badformmsg.htm, add the following lines:
      <img src="/images/load.gif" onload="spellCheck();" >
      The system could not interpret your search statement.
      <div name="spellMessage" id="spellMessage">.</div>

How It Works

When nohitsmsg.htm or badformmsg.htm are accessed (by the user not getting any search results), the tiny GIF image is loaded, calling the spellCheck javascript function found in /js/spell.js.

In spell.js, an XMLHttpRequest object is created and all the search criteria is sent to /spellcheck/spell.cgi.

In spell.cgi, aspell is consulted and returns spelling suggestions, then spell.cgi takes the top suggestion for each word and outputs this information to the JavaScript.

While aspell is being consulted, the user sees the message "Searching for suggestions..." When results are returned, the JavaScript then replaces this message with the new information, where it is printed in nohitsmsg.htm or badformmsg.htm, which happens to be in the middle of the user's web page. Voila!

Troubleshooting

  • You must have root access to compile and install source code and packages.
  • Check the Read Me files for ncurses, libgcc, aspell, and the aspell dictionaries before you install or if you're having trouble installing.
  • Make sure spell.cgi points to the correct Perl installation
    1. Type which perl
    2. Enter the output in the first line of spell.cgi
    3. Example: !#/usr/bin/perl or #!/m1/shared/bin/perl or #!/usr/local/bin/perl

Questions and comments can be sent to Jim Robinson at Tarrant County College.

Last modified: May 07 2007.