Dev Log
 Free Media
 Bob's Gallery
 Links & Resources


 Kana Quizzer
 Keybinding Util
 Model Gallery


 Dev Blog
 Spell Checker
 History Search

Integrate Spell Checker


As a Kizoom developer one wrote, "Users have come to expect spell-check capabilities from applications that involve natural-language text entry." This would probably be the most substantial of the three projects, involving integrating an Open Source Java spell checker API and dictionaries for the user's natural language.


Implementing a spell checker includes a couple of tasks: integrating a spell checker API and finding dictionaries. The first of these is just a matter of comparing the various Open Source implementations of Java spell checkers. In addition to the suggested NetBeans module there's at least four other fairly prominent implementations:

  • JaSpell - Java bindings for Aspell. This is still in beta and seems to be a dead project (it hasn't been updated since 2005).

  • Jazzy - Project based on the Aspell algorithm (using both phonetic matching and sequence comparison). The project has a demo applet and example usage can be found here. While it's certainly usable, it too has been inactive since 2005...

  • JOrtho - An interesting checker that uses dictionaries based on Wiktionary. This is listed as stable and still under very active development. However, I'm a bit dubious about using Wiktionary as the basis for word lists. The site's been rapidly expanding but I'm not sure if it's ready to be used as a reference source for the checker... but then again that's what people once said about Wikipedia...

  • JMySpell - Thanks, Yana, for pointing this one out. This project is picking up where Jazzy left off, implementing a pure Java spell checker. It uses an elegantly simple API and by utilizing the OpenOffice dictionaries it supports over eighty languages. It's still in beta, lacks JavaDocs, and I'm a bit concerned about its stability. However, it's still my favorite choice.

Not only does JMySpell support more languages by using the OpenOffice dictionaries but the word lists are fairly small (60-250 KB). This puts them in the range where we could probably retrieve it during the setup wizard rather than requiring the user to find them separately.

Since both the JOrtho and JMySpell projects are still active and taking unique approaches to their reference lists I'd like to integrate both into the SIP Communicator (defaulting to JMySpell), and allowing the user to toggle the selection. Since languages rapidly change it's quite possible that Wiktionary will more promptly reflect those changes.

For performance reasons the spell checker would only be fired when the keyPressed method handled spaces or the stoppedTypingTimer detected a sizable pause. When either occurred the spell checker would need to check the words on either side of the cursor and underline any misspellings. Future changes within that range of letters would be checked to see if a correction was made. The WritePanelRightButtonMenu would also need to check if the reported click occurred over a word, and if so list possible corrections.

It looks like the spell checker could be implemented as a GUI plugin that adds a KeyListener to make the above changes via the UIService's getCurrentChat().addChatEditorKeyListener() method. However, this would still require access to the editorPane, which currently could be done by casting the Chat to a ChatPanel and calling getChatWritePanel().getEditorPane(). However, this obviously a rather poor solution since it depends on implementation details so I'm currently looking for a better one.

As for the popup menu, even with complete access to the ChatWritePanel I'm not spotting an elegant means of externally intercepting the mouse events to update the popup menu before it appears (if over a misspelled word). The best (or really 'least worst') solution I've come up with so far would be to add a 'ChatPopupMenuAwareComponent' interface (kinda like the ContactAwareComponent) with the following method:

Collection addMenuEntries(ChatWindow window, Point clickCoord)

Which would allow plugins to offer additional menu options based on the context of clicks. However, this is still a rather hacky solution, being far too specific to the needs of the spell checker.