METHOD AND APPARATUS FOR HIGHLrGHTING AUTOMATIC CORRECTIONS OF OPERATOR ERRORS
BACKGROUND OF THE INVENTION
In a computer system that automatically corrects errors made by the user, the user needs some reassurance that the computer system is not introducing errors by mistakenly correcting text that should not be modified. For example, the substitutions proposed by computer systems for names can sometimes yield embarrassing or offensive results. Computer users do not trust computer systems to be infallible, making a user reluctant to use the automatic and interactive correction features. Users dislike audible methods of highlighting errors as the user types because they find them to be annoying. Most users turn off audio warnings.
This invention may be included in computer systems that automatically correct errors as the user types using the keyboard. It overcomes the drawback of other systems; namely, many users are unwilling to allow the computer system to invisibly correct errors as they type because they may not notice when the computer system has made an unacceptable automatic correction.
This invention may be included in computer systems that correct errors in an interactive session. It has a significant advantage over prior systems. The computer system keeps track of all the substitutions made during the interactive session and then allows the user to toggle the highlighting of all substitutions for a final check.
SUMMARY OF THE INVENTION Briefly, according to this invention, there is provided a computer implemented system and method for highlighting corrections automatically made to a word or words in a computer text file or stream. By computer text file is meant an ASCII or other standard text file comprised of bytes representative of alphanumeric characters grouped together to represent words. By text stream is meant a series of bytes representative of alphanumeric characters grouped to represent words being transferred serially or in
parallel into the computer from a file, keyboard, modem or some other device.
Current computer systems for the correction of errors, such as spelling checkers and grammar checkers, highlight the errors allowing the user to correct the errors, possibly with assistance from the computer system. Briefly, according to this invention, there is provided a computer system or computer implemented method for highlighting corrections that were made automatically by the computer as the user typed or during an interactive session. This allows the user to review the corrections for accuracy, giving assurance that new errors will not be unwittingly introduced.
The computer system or method according to this invention highlights corrections automatically made as the user types or during an interactive session after typing. The computer not only highlights that substituted text but may also highlight positions where words were deleted and permits the user to temporarily or permanently undo or revise the correction. For example, a status line can be used to show a misspelled word that was corrected as the user passes the mouse cursor near the highlighted word.
In a preferred embodiment, the computer system or method permits the user to use the mouse cursor to point to and click on the highlighted correction to bring up a dialog box or menu showing the original word, the correction, and possibly an explanation of the type of error and a list of close alternatives.
Since the highlighting of corrections, according to this invention, is intended to be used in conjunction with methods of highlighting errors, a different highlighting method must be used for corrections and errors. According to preferred embodiments, steps are provided for highlighting corrections and errors differently according to the degree, probability, severity and type. Moreover, the operator may selectively turn on and off error type and may configure the highlighting method to satisfy
personal preference. For example, the operator may have the option of having displayed only those corrections in the current paragraph (e.g., the paragraph containing the cursor) or in the entire document. BRIEF DESCRIPTION OF THE DRAWINGS
Further features and other objects and advantages will become clear from the following detailed description made with reference to the drawings in which:
Fig. 1 is a flow diagram for a portion of a nonsticky font computer program which after identification of a correction highlights the correction; and
Fig. 2 is a flow diagram for a portion of a sticky font computer program which after identification of a correction highlights the correction. DESCRIPTION OF THE PREFERRED EMBODIMENTS
Two main methods can be used to highlight automatic corrections. Both are triggered when, for example, a spelling correction program detects an error and is about to substitute a replacement. If the program can associate visual attributes with text strings, such as color, the program can apply these attributes directly to the replacement string or text before the substitution occurs. (Other highlighting techniques are discussed hereafter.) Otherwise, the highlighting code can note the start and end positions of the incorrect text, replace it with the proposed correct text, calculate the new end positions (the original start position plus the length of the replacement text) and then apply the visual attributes to the region of the document corresponding to the replacement text.
With both methods, it is important to know whether the visual attributes are "sticky" and how to terminate the sticky attributes. Some word processors embed start and end codes for visual attributes in the document file itself. For such systems, the highlighting code just needs to insert the start and end codes at the appropriate positions in the document file. Some word processors automatically copy the
visual attributes from one character to the next unless an explicit change in attributes occurs. Such attributes are called "sticky". The GNU-Emacs word processing program has sticky font attributes. In such a system, it is necessary to explicitly unhighlight the space that follows the replacement.
Referring now to Fig. 1, there is illustrated in flow diagram form a program segment for highlighting corrections made by a spelling correction program wherein the attributes are not "sticky". At 10, a word is read from the document file stored in active memory. At 11, the spelling correction program determines if the word is correctly spelled and proposes a replacement if the word is not correctly spelled. If at 12 it is determined that no replacement is proposed, the program loops back to get the next word. If the word is to be replaced, the original text is deleted at 13 and the proposed correction is inserted at 14. Finally, the replacement is highlighted at 15.
Referring now to Fig. 2, there is illustrated in flow diagram form a program segment for highlighting a correction for a word processor program with "sticky" attributes. Steps 20 to 25 are identical to steps 10 to 15 described with reference to Fig. 1. An additional step 26 is required to unhighlight the trailing white space. Example from GNU-Emacs Implementation
The GNU-Emacs implementation begins with a set of parameters that controls the operation of the highlighting.
; ; ; This parameter controls whether highlighting is active ; ; ; or not. (defvar *highlight-corrections*)
(setq *highlight-corrections* t)
These parameters control the realization of highlighting in terms of font attributes such as underlining and the choice of color. For highlighting that just consists of ; ; ; underlining, setting *highlight-color* to NIL will cause it to use the default color (black) .
(defvar *highlight-color*) (setq *highlight-color* "red")
Since the GNU-Emacs font attributes modify fonts, not individual characters, we initiate the highlighting by
setting attributes of the underline font," and then applying the underline font to the text to be highlighted. In other systems, where font attributes, like color, can be applied to individual characters, font attributes are applied directly to the text instead of indirectly by modifying the font. One benefit of the GNU-Emacs implementation is that we can temporarily remove the highlights by removing the highlighting attributes from the underline font, making it appear like normal text. The highlighted text is still in the underline font, so when restoring the highlighting attributes to the underline font, the corrected text becomes highlighted again. In other systems, the location of the corrected substitutions or embed hidden markers in the text would have to be specifically recorded in order to be able to temporarily suppress the highlighting of the substituted text.
The code that initializes the use of automatic correction must include the following line to set up for highlighting of corrections: (set-face-foreground 'underline *highlight-color*)
In the code that does the replacement of the correct for incorrect text, some code must be called to execute the highlighting. The following is the complete code for the replacement function in order to show how the highlighting uses information from the replacement.
(defun replace-region (start end replacement position
&optional delstart no-highlighting) (let ( (offset 0) ) (goto-char start) 5 (if (string-equal replacement "" ) (progn
(if (re-search-forward "[\n\t ]" position 1) ; was (point-max) (progn
(re-search-forward "[Λ\nΛ\tΛ ] " position 1) 10 (backward-char 1)))
(setq end (max end (point))) (if delstart (progn
(goto-char start) 15 (if (re-search-backward "[\n\t ]" (point- in) 1)
(progn
(re-search-backward "fΛ\nΛ\tΛ ]" (point-min) 1) (forward-char 1 ))) , (setq start (min start (point)))))))
^ 20 (delete-region start end)
, (setq offset (- (length replacement) (- end start)))
(setq position (+ position offset) ) (insert replacement) (if (and *highlight-corrections* 25 (not no-highlighting)
(not (string-equal replacement ""))) (highlight-region start (point) ) ) position) )
The final IF statement is where the highlighting occurs. It checks whether highlighting is enabled, whether the call to this function is suppressing highlighting using the no-highlighting argument, and whether the replacement is actually a deletion (in which case it does not make sense to highlight something that is not there) . The no-highlighting argument from this function allows suppression of this use of highlighting in the call to this function. For example, the following call to replace-region from the automatic correction code checks whether the replacement is equal to the original word. If this is the case, it is a null substitution and so the replacement should not be highlighted. (This can happen whenever the correction involves a previous word.) (if replacement
(setq position
(replace-region start end replacement position t (string-equal word replacement)))) (if prev-replacement (setq position
(replace-region prev-start prev-end prev-replacement position nil (string-equal prev prev-replacement) ) ) )
Since the automatic correction is triggered by the typing of a white space character in this implementation and
GNU-Emacs font attributes are sticky, the white space character will also be highlighted. Thus, immediately after the white space character is inserted in the document, the following code must be called to remove the highlighting from the white space character. Any following characters will inherit the non-highlighting attributes of the white space character.
(if *highlight-corrections*
(unhighlight-region (- (point) 1) (point))) The following code defines support functions that are used in the above code and to affect the behavior of the highlighting.
; This function turns highlighting on and off, either by toggling ; the current status of the *highlight-corrections* parameter, or ; by forcing it on. (defun highlight-corrections (Soptional arg)
"Toggle correction highlighting. With argument ARG, turn on highlighting iff ARG is positive." (interactive "P") (setq *highlight-corrections*
(if (null arg) (not *highlight-corrections*)
10 (> (prefix-numeric-value arg) 0))) (if *highlight-corrections* (show-highlights) (hide-highlights) ) )
; The following function removes the highlighting font attributes
15 ; from all the text in the document. This permanently removes the ; highlighting, (defun remove-highlights ()
"Permanently removes the highlighting."
I (interactive) O 20 (unhighlight-region (point-min) (point-max) ) ) I
The following function temporarily unhighlights the corrected text by removing the color and underline attributes from the underline font, (defun hide-highlights ()
25 "Temporarily removes the highlighting." (interactive)
(set-face-foreground 'underline nil) (set-face-background 'underline nil) (set-face-underline-p 'underline nil) )
30 The following code restores the highlighting attributes to the underline font, restoring the highlights to the replacement text throughout the document.
(defun show-highlights ()
"Restores the temporarily hidden highlighting."
(interactive)
(set-face-foreground 'underline *highlight-color*) ; (set-face-background 'underline nil)
(set-face-underline-p 'underline t) )
; The following code highlights the text in the region from ; the start position to the end position by changing the ; font of that region to the underline font,
10 (defun highlight-region (start end)
(face enu-set-face 'underline start end) )
; ; ; The following code unhighlights the text in a region by ;;; setting the font in the region to the default font, (defun unhighlight-region (start end)
15 (facemenu-set-face 'default start end))
I The following function is a utility function for extracting the text in a region with font highlighting attributes removed, I to allow comparisons with other plain text strings, (defun bufstring (start end)
20 ; ; (buffer-substring start end)
(buffer-substring-no-properties start end) )
Highlighting Techniques Different highlighting methods can be used according to the type of error (e.g., typographical error, spelling error, grammatical error, diction error, use of British spelling, slang, etc.). The degree of severity of the error and correction may be indicated as by highlighting in a more visible fashion. For example, an offensive word correction may be indicated in the most intense fashion. Also, the probability that the misspelled word was indeed an error may be indicated in the same way.
Highlighting techniques include color, intensity, underlining, changing case, reverse video, differences in font attributes, such as bold, italics and font size or font set width. Additional highlighting techniques include strike through and X marks, encircling the correction, boxing the correction, blinking or flashing text, arrows and margin indicators. Combinations of the above are contemplated, for example, colored underlines, colored text and colored reverse video. It is possible to display the proposed error with the correction, for example, showing the old text with one highlighting method followed by the correction with a different method.
Preferably, the user can turn the highlighting mode on and off, toggle whether the highlights are visible or not and permanently remove highlighting information. Also, it is preferred that the highlighting method for each category of correction is user configurable. The highlights may be either printable or nonprintable, as the user desires. The highlights can be applied to the entire correction or just the letters that were changed.
Having thus defined our invention in the detail and particularity required by the Patent Laws, what is desired protected by Letters Patent is set forth in the following claims.