Creating Custom Dictionaries for Ephox EditLive! for Java

Introduction

Custom dictionaries may be created for use with Ephox EditLive! for Java.  Custom dictionaries are used to add words to an existing dictionary used by the spell checker for EditLive! for Java.  This document details how to extend the existing dictionary of a spell checker used by EditLive! for Java.  This requires some skill with unzipping files and using the Java jar command.

Users can also add words to the dictionary which are then stored locally on the client.  Any words added to the local dictionary by users will persist on the client even when the dictionary is updated on the server.  Words are added to the local dictionary when a user clicks the "Add Word" option on the spell checker.

Specifying a Custom Dictionary

  1. In order to add a custom dictionary to an existing spell checker the existing spell checker .jar file must first be unzipped.  This file can be found in the webfolder/redistributables/editlivejava directory of your EditLive! for Java install.  The name of this .jar file will vary with the spell checker your version of EditLive! for Java is using.  Typically the name of the .jar file will be capitalized.  If in doubt as to the name of your existing dictionary please see either the document on Using Different Spell Checkers with Ephox EditLive! for Java or the <spellCheck> XML element.  

    For the purposes of this document and the example contained herein it will be assumed that the spell checker concerned is named en_us_2_0.jar.

    Once you have found this file use a file unzipping utility to extract the contents of the file.  In order to complete the steps required to create a custom dictionary the spell checker file should be unzipped to a new directory which, initially, contains only the content extracted from the .jar file.
  2. If the file has been extracted correctly from the zip file there should now be two directories in the directory to which the file was unzipped.  Note that these directories should currently be the only listings within this directory.  These directories are com and META-INF.  For the creation process to proceed correctly delete the META-INF directory from the directory.

    Note:  If a custom dictionary has already been created for this spell checker there will also be a file named userdic.tlx present in the directory to which the .jar file was extracted.  If this is the case and you wish to extend the existing custom dictionary then do not delete this file.  For more information on this please see the Modifying the Current Custom Dictionary section of this document.  If you wish to remove the current custom dictionary then delete this file.  For more information on this please see Removing the Current Custom Dictionary section of this document. 
  3. With a plain text editor create a file called userdic.tlx in the directory to which the contents of the .jar file were extracted.  This file will be where the listings for the custom dictionary are placed.
  4. At the top of the new file place the following line:

        #LID 24941
  5. For each word that you wish to place into the custom dictionary list the word in the userdic.tlx file on its own line.  Then, one tab spacing from the word, place an "i".  Thus, lines in the file should appear in the following format:

        customword    i
  6. Repeat step 5 for all the words you wish to add to the custom dictionary.  When finished save the userdic.tlx file.
  7. After saving the userdic.tlx file the .jar file must be recompiled.  This requires using the Java jar command at the command line in the directory to which the contents of the original .jar file were extracted.  

    For example, if the location of the directory to which the contents of the original .jar file were extracted was C:\OriginalJar\ , the location of the jar command was C:\java\bin\jar and you wished to name the new .jar file customdict.jar then the command line would be as follows:

        
    C:\java\bin\jar cvf customdict.jar .

    Note:  This command is as it would appear if you were currently browsing the directory to which the original .jar file was extracted via the command prompt.
  8. Move the newly compiled .jar file, in the case of the example above the file would be called customdict.jar to a location where it may be accessed by the EditLive! for Java applet.
  9. Edit the configuration information for EditLive! for Java to reflect the location of the new spell checker.  For more information on how to do this see the Setting the Spell Checker for EditLive! for Java section of this document, the document on Using Different Spell Checkers with Ephox EditLive! for Java or the <spellCheck> XML element. 

Modifying the Current Custom Dictionary

  1. Perform steps 1 and 2 as above in the Specifying a Custom Dictionary section of this document.
  2. Open the userdic.tlx file in a plain text editor.
  3. For each word that you wish to add to the custom dictionary list the word in the userdic.tlx file on its own line.  Then, one tab spacing from the word, place an "i".  Thus, lines in the file should appear in the following format:

        customword    i
  4. Repeat step 3 for all the words you wish to add to the custom dictionary.  When finished save the userdic.tlx file.
  5. After saving the userdic.tlx file the .jar file must be recompiled.  This requires using the Java jar command at the command line in the directory to which the contents of the original .jar file were extracted.  The name of the new spell checker .jar file is specified in this step.

    For example, if the location of the directory to which the contents of the original .jar file were extracted was C:\OriginalJar\ , the location of the jar command was C:\java\bin\jar and you wished to name the new .jar file customdict.jar then the command line would be as follows:

        
    C:\java\bin\jar cvf customdict.jar .

    Note:  This command is as it would appear if you were currently browsing the directory to which the original .jar file was extracted via the command prompt.
  6. Move the newly compiled .jar file, in the case of the example above the file would be called customdict.jar to a location where it may be accessed by the EditLive! for Java applet or save it in place of the old file.  

    If the name of the new custom dictionary differs from the old one then edit the configuration information for EditLive! for Java to reflect the location of the new spell checker.  For more information on how to do this see the Setting the Spell Checker for EditLive! for Java section of this document, the document on Using Different Spell Checkers with Ephox EditLive! for Java or the <spellCheck> XML element.

Removing the Current Custom Dictionary

  1. Perform steps 1 and 2 as above in the Specifying a Custom Dictionary section of this document.
  2. Delete the userdic.tlx file from the directory to which the contents of the original .jar file were extracted.
  3. After deleting the userdic.tlx file the .jar file must be recompiled.  This requires using the Java jar command at the command line in the directory to which the contents of the original .jar file were extracted.  The name of the new spell checker .jar file is specified in this step.

    For example, if the location of the directory to which the contents of the original .jar file were extracted was C:\OriginalJar\ , the location of the jar command was C:\java\bin\jar and you wished to name the new .jar file customdict.jar then the command line would be as follows:

        
    C:\java\bin\jar cvf customdict.jar .

    Note:  This command is as it would appear if you were currently browsing the directory to which the original .jar file was extracted via the command prompt.
  4. Move the newly compiled .jar file, in the case of the example above the file would be called customdict.jar to a location where it may be accessed by the EditLive! for Java applet or save it in place of the old file.  

    If the name of the new custom dictionary differs from the old one then edit the configuration information for EditLive! for Java to reflect the location of the new spell checker.  For more information on how to do this see the Setting the Spell Checker for EditLive! for Java section of this document, the document on Using Different Spell Checkers with Ephox EditLive! for Java or the <spellCheck> XML element.

Setting the Spell Checker for EditLive! for Java

The spell checkers for EditLive! for Java for different languages are each packaged as separate files.  In order to configure EditLive! for Java to use a spell checker the program must be informed of the location of the relevant spell checking package, this occurs via the EditLive! for Java XML configuration.  The <spellCheck> element of the EditLive! for Java XML configuration provides EditLive! for Java with the location of the spell checker package which it is to use.  The location is specified as a URL which can be either relative or absolute.  For more information please see the article on Using Different Spell Checkers with Ephox EditLive! for Java.

Example

This is an example of a full userdic.tlx file that can be used to extend a current dictionary.

#LID 24941
customdict    i
Ephox    i
EditLive    i
Java    i
HTML    i
XML    i

Summary

The dictionary to be used with EditLive! for Java can be extended to include words which are not in the standard dictionary.  This is done by including a file called userdic.tlx in the .jar file of the spell checker which is used by EditLive! for Java.  The included file should contain all the words which are to be added to the EditLive! for Java spell checker.  

See Also