Live data from Hacker News

How to Write a Spelling Corrector

norvig.com

41–50 of 133 posts

Re: How to Write a Spelling Corrector

#41
post #18
post #3

Spell chequer Martha Snow Eye halve a spelling chequer It came with my pea sea It plainly marques four my revue Miss steaks eye kin knot sea. Eye strike a quay and type a word And weight four it two say Weather eye am wrong oar write It shows me strait a weigh. As soon as a mist ache is maid It nose bee fore two long And eye can put the error rite It's rare lea ever wrong. Eye have run this poem threw it I am shore y…

In a way, I'm surprised I can read this so easily. Do our brains read by converting text to sounds, and then parsing the sounds?

Honestly it took me a minute before my brain started to be able to read it a lot better. At least it was very slow because everything is so wrong. So I don't know how common either of our experiences are but I am your contrary :)

Re: How to Write a Spelling Corrector

#42
Is there any C++ version of a decent spell checker ? Been looking for sometime (mainly out of curiosity), most are either amateur school projects or too academic/phd-ish....would love to go through a good open source C++ based spell checker that can be used in practise (with little modifications if required)

Re: How to Write a Spelling Corrector

#44

His python code styling is really awesome. So concise. Probably inspired by all the LISP he wrote in the past. Although he does seem to be using doc strings incorrectly

Came here to say this. I've combed through his pieces many times over just to glean the way he structures his code. Here, he got my head spinning for a minute with return set(w for w in words if w in WORDS) and made a mental note to use that idiom in the future. As for doc strings, well, this is just a toy piece of code after all. The main purpose for the code is to be read, instead of actually used. something someth…

You can also use the set-comprehension syntax, which functions equivalently but looks slightly nicer:

    return {w for w in words if w in WORDS}
could have also directly used the intersection operator on the sets:

    return words & WORDS
or slightly more verbose, but maybe more clear for colleagues who don't regularly use sets in Python:

    return words.intersection(WORDS)

Re: How to Write a Spelling Corrector

#45

His python code styling is really awesome. So concise. Probably inspired by all the LISP he wrote in the past. Although he does seem to be using doc strings incorrectly

Came here to say this. I've combed through his pieces many times over just to glean the way he structures his code. Here, he got my head spinning for a minute with return set(w for w in words if w in WORDS) and made a mental note to use that idiom in the future. As for doc strings, well, this is just a toy piece of code after all. The main purpose for the code is to be read, instead of actually used. something someth…

that is a great idiom. i remember the first time i saw it (possibly in is very essay), i thought it was awesome. I use it all over the place now. it is similiar to the javascript ternary operator [1], which I also find to be very useful

   var varX = (boolean) ? 'X' : 'Y'
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re: How to Write a Spelling Corrector

#46

His python code styling is really awesome. So concise. Probably inspired by all the LISP he wrote in the past. Although he does seem to be using doc strings incorrectly

Notable for code archaeology: the docstrings weren't in the previous version[].

(He also switched from manually implementing counting behavior with a Dict to a Counter, added the P function which replaces an inline dict lookup, similarly added the candidates function, changed the somewhat awkward known_edits2 function to just edits2, and reorded some things.)

[] http://web.archive.org/web/20160408180602/http://norvig.com/...

edit: small edits

Re: How to Write a Spelling Corrector

#47
post #18
post #3

Spell chequer Martha Snow Eye halve a spelling chequer It came with my pea sea It plainly marques four my revue Miss steaks eye kin knot sea. Eye strike a quay and type a word And weight four it two say Weather eye am wrong oar write It shows me strait a weigh. As soon as a mist ache is maid It nose bee fore two long And eye can put the error rite It's rare lea ever wrong. Eye have run this poem threw it I am shore y…

In a way, I'm surprised I can read this so easily. Do our brains read by converting text to sounds, and then parsing the sounds?

Early reading is taught that way. You may have heard of "Phonics" as an element of literacy?

Full literacy in alphabetic-phonetic languages includes the steps of (1) no longer sounding out words aloud and (2) no longer sounding out most words in your head, but rather grasping the shape of the word immediately.

Re: How to Write a Spelling Corrector

#48
post #3

Spell chequer Martha Snow Eye halve a spelling chequer It came with my pea sea It plainly marques four my revue Miss steaks eye kin knot sea. Eye strike a quay and type a word And weight four it two say Weather eye am wrong oar write It shows me strait a weigh. As soon as a mist ache is maid It nose bee fore two long And eye can put the error rite It's rare lea ever wrong. Eye have run this poem threw it I am shore y…

Her spell checker works great, but it looks like she needs a grammar checker too.

Re: How to Write a Spelling Corrector

#50
post #42

Is there any C++ version of a decent spell checker ? Been looking for sometime (mainly out of curiosity), most are either amateur school projects or too academic/phd-ish....would love to go through a good open source C++ based spell checker that can be used in practise (with little modifications if required)

What's wrong with Aspell? (Not saying you're wrong; just wondering what I've missed.)
Post reply on HN