SpellingHistoryclass | spelling.t[444] |
Superclass Tree | Subclass Tree | Global Objects | Property Summary | Method Summary | Property Details | Method Details |
The point of maintaining a history is that it allows us to backtrack if we decide that an earlier guess at a corrected word isn't going to result in a working command after all. If an earlier correction had other equally good options, we can go back and try the other options by unwinding the history.
class
SpellingHistory : object
corrections
cstack
parser
startTime
checkSpelling
clear
construct
hasCorrections
noteSpelling
rollback
corrections | spelling.t[786] |
cstack | spelling.t[795] |
parser | spelling.t[775] |
startTime | spelling.t[778] |
checkSpelling (toks, err) | spelling.t[470] |
'toks' is the token list for the command line, and 'err' is the ParseError object indicating what error triggered the spelling check.
Returns a new token list if we correct a spelling error, nil otherwise.
clear ( ) | spelling.t[800] |
construct (parser) | spelling.t[445] |
hasCorrections ( ) | spelling.t[455] |
noteSpelling (newToks) | spelling.t[699] |
rollback (toks, err) | spelling.t[660] |
If 'err' is a curable error, we'll leave things as they are. The curable error means that the token list is now well-formed, but is missing some information we need to actually execute it. Since it's well-formed, our spelling corrections must have made some kind of sense, so we'll assume they were correct.
If the error isn't curable, though, our spelling corrections didn't result in a working command. The way we pick candidate words tends to give us lots of false matches, so the fact that we didn't end up with meaningful syntax overall suggests that our guess for an individual word was a spurious match.
To determine what we keep and what we roll back, we look at whether a change improved the intelligibility of the command. There are basically three stages of intelligibility that we can distinguish: (1) completely unintelligible, (2) valid verb structure but unknown noun phrases, and (3) valid verb structure AND resolvable noun phrases.
We want to keep any attempted spelling corrections that successfully advanced us from one stage to the next, because the improved intelligibility is pretty good evidence that our corrections were in fact correct. We DON'T want to keep any corrections that didn't advance the process, because we can't tell if they actually helped. We're intentionally conservative about spelling correction, because spurious corrections are worse in an IF context than in most applications. In IF, a spurious correction could be a spoiler, by revealing the existence of a dictionary word too early in the game. To reduce spurious corrections, we only accept corrections that actually make the command more parseable.