application/x-abiword
AbiWord
Tue Dec 3 20:33:01 2002

THIS DOCUMENT IS OUT OF SYNC WITH THE CODE. PLEASE IGNORE FOR NOW.

$Id: AbiWord_SpellCheck_Notes.abw,v 1.5 2002/12/04 01:37:35 dom Exp $

AbiWord SpellCheck Design Notes

Copyright (C) 1998 AbiSource, Inc. All Rights Reserved.

Jeff Hostetler, jeff@abisource.com

AbiSource, Inc.

$Date: 2002/12/04 01:37:35 $

Introduction

This document provides preliminary design notes for SpellChecker integration into AbiWord.

Overview

AbiWord will integrate a third-party GPL'd spelling checker. It will be built as a library and linked with AbiWord; it will not use a separate executable or process. The source for this library will be located in a directory under the abi/src/other/ directory.

Conceptually, the SpellChecker may be divided into the following parts:

1. Code which resides in the Format/View code that determines which portions of the document are unchecked and either performs the check or schedules them for checking. (VIEW)

2. Code which draws squiggly red lines under incorrect words, and provides various GUI interaction with the user, such as a context-menu to suggest alternatives and any dialogs. (GUI)

3. Code which implements the dictionary lookup and composes alternatives for misspelled words. This code will be adapted from existing third-party GPL sources. (LOOKUP)

4. Code which updates the document for ignoring words on an individual-instance and document-instance basis. (DOC)

5. Code which updates the user's document-independent ignore list. (PREF)

VIEW Details

The VIEW-related code will execute in the Main UI Thread[1] and be periodically invoked (by a timer) during idle times. It will directly interact with Format/View data structures and be synchronized with them. It will not have a thread of its own. The LOOKUP-related code may need a thread of its own, depending upon its speed and design, but we won't make that decision at this time.

The VIEW will maintain a series of data structures identifying the unchecked pieces of the document; this will consist of a beginning and ending DocPosition. It will contain a priority indication, such as: Change, OnScreen, and Document. Each time that the SpellCheck timer code runs, it will attempt to do a little bit of the spell checking, beginning with the highest-priority, and return. In this manner, we will appear to be quite responsive and able to keep the area around the user's typing and the area exposed on the screen up-to-date; as additional idle time is available we will do pieces of the rest of the document so that it will be ready if/when the user scrolls.

(Handwave) The VIEW will also make use of the existing Block and Run data structures to record the results of previous spell checks. This includes: Correct, IgnoreThisInstance, IgnoreInThisDocument, Wrong, etc.

GUI Details

The GUI for SpellCheck should include:

1. Variations on the red squiggly line.

2. Context menu listing alternatives or to ignore this instance.

3. Various dialogs.

LOOKUP Details

The LOOKUP engine should provide an API to allow the timer code to request a spell-check on a passage. Whether this executes in-thread or uses its own thread is a detail we can address after we choose and port a third-party engine.

DOC Details

The AbiWord Document Format[2] will need to augmented to remember span-level attributes for text marked IgnoreThisInstance and to remember document-level attributes for text marked IgnoreInThisDocument.

PREF Details

(Handwave) The AbiWord User Preference Mechanism[3] will need to be augmented to remember words that should always be ignored.

References

[1] AbiWord Thread Design Notes....

[2] AbiWord Document Format ....

[3] AbiWord User Preference Mechanism ....