5 ms·
Maybe it's not fair to cite the work of super heroes, but Peter Norvig wrote a spelling corrector in 21 lines of Python: http://norvig.com/spell-correct.html ht
by rcfox 15y ago
Maybe it's not fair to cite the work of super heroes, but Peter Norvig wrote a spelling corrector in 21 lines of Python: http://norvig.com/spell-correct.html http://norvig.com/spell-correct.html
- Radim 15y agoIt is fair, it is a first step in that direction :-) That corrector has no context though, so it will not correct misspelled words that happen to come out as other words (incl. the "Their coming too sea if its reel."). This is especially important on the web, where pretty much every conceivable word is "correct" (a name of a company or otherwise). False positives are costly, and context disambiguation critical. Let the fun begin.
- dextorious 15y agoYou keep using this word "spelling". I don't think it means what you think it means. This is GRAMMAR checking, or at least grammar-assisted spell checking. Very few, if any, shipping mainstream spelling correctors do that.
- Radim 15y agoPeople want their documents (or queries) free of spelling errors. That is their pain and that is the challenge. The example sentence has misspelled words, hence is within the domain of spell checking. This type of misspelled words are called "homonyms", which are one very common spelling problem. The academic terminology is uninteresting to most users, however. Or if you mean to posit that "spell checking really means looking up if a word exists in a static dictionary of English", then yes, that's easy and solved, no argument there.
- tincholio 15y ago> The example sentence has misspelled words, hence is within the domain of spell checking. No, it doesn't . It is grammatically incorrect, but all the words are spelled correctly. You're definitely talking about a grammar checker, not a spelling checker.
- Radim 15y agoI understand this is a mismatch in terminology. In your view, "spelling check" is applied to individual words, to see if they appear in a fixed dictionary (see my other comment about difficulties with choosing this "correct" dictionary in reality, though). I can imagine this view is inviting for programmers, because it's easy to implement, but I doubt anyone else finds useful a definition that says there are no misspellings in "Their coming too sea if its reel." In my view, "spell check" applies to utterances and roughly means "all words are spelled as per the norm of the language; I can send this document to my boss/customer and they won't laugh at my spelling." It is a more user-centric view, and more complex too, because it covers intent and norms, as opposed to the comforting lookup table for a few hand-picked strings. Modern spell checkers make heavy use of statistical analysis of large text corpora, to reasonably approximate context needed to model such intent. Once we agree on the terminology, I believe we are in agreement, so let's not split hairs. The "correctly spelled" sentence under question comes from the Wikipedia article on spell checking, by the way.
- bermanoid 15y agoI can imagine this view is inviting for programmers, because it's easy to implement, but I doubt anyone else finds useful a definition that says there are no misspellings in "Their coming too sea if its reel." I realize this is just a debate over a definition, so it's not very meaningful, but the fact is, you're on the wrong side of the common definition here. I just tested, and every spell checker that I just checked (Chrome, Firefox, MS Word, TextMate, TextEdit - perhaps some of these rely on the same underlying engine, I'm not sure?) accepts that sentence as not having a spelling error, so clearly there's some use for such a definition. The grammar checkers, on the other hand, don't like it, but by changing "their" to "they're", they all accept it, despite the fact that it's still garbage. So don't overestimate how good "modern" spell checkers are...though there may be techniques to do a better job, they're not in common use, at least in the most common spell-checking contexts (which, lets be honest, pretty much means MS Word).
- gjm11 15y agoThere is no question whatever: the sentence contains misspelled words. "They're" is misspelled as "Their", "to" as "too", "see" as "sea", etc. There is also no non-words. It happens that today's spelling checkers are generally just non-word detectors. This doesn't mean that anyone defines "misspelled" to mean "misspelled in such a way that the result is not a word at all". And yes, a non-word detector is still very useful, and it's much much easier to make than something that also determines reliably when words are misspelled in ways that produce other words, so there's lots of software out there (perhaps essentially all of it) that contains only a non-word detector. I think it's perfectly reasonable to define "spelling checker" to include mere non-word detectors. Or for that matter non-common-word detectors. (I expect most spelling checkers will reject "hight", and very sensibly because if someone types that they probably meant "high" or "height" or something -- but it's a perfectly good word, albeit a rare and archaic one.) But there's no way it's correct to say that "sea" isn't misspelled in that sentence merely because the mistake happens to have produced something that's an English word.
- rcfox 15y agoHey, here's a chance to invent some new terminology! I would say that Norvig's corrector is a first-order spelling corrector, since it works within the context of a single word. A second-order corrector would take into account the word before or after it to choose the spelling that is more likely to make sense. ("Their coming" would suggest a correction to "They're coming") Third-, fourth-, (and so on) order expands the distance of words considered.
- dextorious 15y ago"""("Their coming" would suggest a correction to "They're coming")'"" How about: "Her relatives would visit us for Christmas. Their coming filled us with dread!"
- rcfox 15y agoIt's valid, but less common, and that's why I specifically chose the wording "suggest a correction" instead of "correct". Spell checkers are still no substitute for actual thought.
- regularfry 15y agoNo, it's spell-checking. Use of the word "reel" in this sentence, for instance, is definitely a spelling error. There's no grammatically valid form of the word "real" spelled with two 'e's. The fact that "reel" happens to be a valid word doesn't mean that its presence in the sentence is due to a grammatical error - it's just an accidental collision. That no spell checker might be able to catch this specific class of error doesn't change the type of error it is.
- Radim 15y agoIncidentally, the linked article by Peter Norvig also mentions that adding context is the best way to improve spelling correction. If you think this claim is so controversial, explain yourself, don't just downvote please.