Skip navigation

I wrote a C++ version of the Norvig’s spelling corrector. The theory and other language implementations are in his website, and my version can be found at my github:



  1. HOLA… Q TAL…
    Ps yo ando buscando opciones d como hacer un este proyecto pero poner agregarlo al openoffice con palabras de alguna lengua indigena…. y necesito material q me sirva de guía primero para entnder como se hace y dspués aterrizarlo al problema q quiero resolver…

    Me pueds mandar x favor el código… O más o menos orientarme al respecto d q si es posible hacer esto que quiero… Desarrollar un corrector que tenga diccionarios de palabras en alguna lengua indigena y psoteriormente agregarlo al openoffice, o sólo se podrían agregar diccionarios???…

    En vd necsito esta información y agradeceré me contest…


  2. Para que coño quieres meter una lengua indigena si los tios estos no saben ni que es un ordenador !!

    • Habra gente que quiera aprender a usar alguno 🙂

  3. Hi Felipe,
    Well done, thank you.
    How do you think is it possible to do some optimization to make code faster?

    Best regards,

  4. Hey Oleg,

    Thank You 🙂
    The code is actually running pretty fast but yes, it can still be improved, I think I will write another post in the blog just for that subject ok?

    Felipe Farinon.

  5. Thanks for the code
    I think there’s a bug in the code. The transposition edit should be
    word.substr(0, i) + word[i+1] + word[i] + word.substr(i + 2) instead of word.substr(0, i) + word[i+1] + word.substr(i + 2)

    • Yes, there was, thank you for pointing it. The fixed code is at github.

  6. podrias acesorarme para hacer un corrector ortografico en visual basic

  7. podrias mandarme lo comentarios a mi correo o a cualquier persona que lea este mensaje

  8. Awesome…thanks

  9. nice code. 🙂

  10. Hi, i got a problem with this program, can you tell me witch tool do you use ?
    and what is the type of file for the last program , and his complete name ?
    Thank you,

  11. hey Felipe,
    I would like to use ur code in a mex file on matlab. I am working on an OCR application and I want to implement ur code for post processing of words. The link for the word database is broken. Can you shoot me an update for that link on my email. Thanks in advance.

  12. I am using this in my spell checking library libspellcheck (

  13. I think you missed word[i] after word[i+1] in transposition section of edit(). As transposition assume to swap to adjacent. Please correct me if I am wrong. Great work though.

    • You are right, thank you for spotting it. This made the corrector fail in two of the tests listed by Norvig, the ones which had the word ‘peotry’ and ‘peotryy’.

      I’m uploading the correction.

  14. Hi Felipe, I took some parts of your code as well, thanks!
    I think I found a little bug other than the one pointed by Yassine: in the load function the “++i” increment makes you skip the first letter of the first word of the dictionary file, leading you to record a wrong word.

  15. You can write a spell corrector using elasticsearch. Here is the link .

7 Trackbacks/Pingbacks

  1. By Maps using string keys « Felipe Farinon on 17 Mar 2009 at 1:42 pm

    […] in C++ In the spelling corrector article we read a whole file in memory and hold it’s data in a std::string object, and then we use a […]

  2. By Spellbound « newlisper on 08 Feb 2011 at 2:42 pm

    […] Felipe Farinon […]

  3. […] Felipe Farinon […]

  4. […] Felipe Farinon […]

  5. […] Felipe Farinon […]

  6. By Yazım kontrol uygulaması | on 10 Jan 2020 at 8:12 am

    […] Felipe Farinon […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: