Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7517895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:35:49+00:00 2026-05-30T01:35:49+00:00

Recently I’ve looked through several spell checker algorithms including simple ones(like Peter Norvig’s )

  • 0

Recently I’ve looked through several spell checker algorithms including simple ones(like Peter Norvig’s) and much more complex (like Brill and Moore’s) ones. But there’s a type of errors which none of them can handle. If for example I type stackoverflow instead of stack overflow these spellcheckers will fail to correct the mistype (unless the stack overflow in the dictionary of terms). Storing all the pairs of words is too expensive (and it will not help if the error is 3 single words without spaces between them).
Is there an algorithm which can correct (despite usual mistypes) this type of errors?

Some examples of what I need:
spel checker -> spell checker
spellchecker -> spell checker
spelcheker -> spell checker

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:35:51+00:00Added an answer on May 30, 2026 at 1:35 am

    I hacked up Norvig’s spell corrector to do this. I had to cheat a bit and add the word ‘checker’ to Norvig’s data file because it never appears. Without that cheating, the problem is really hard.

    expertsexchange expert exchange
    spel checker spell checker
    spellchecker spell checker
    spelchecker she checker  # can't win them all
    baseball base all  # baseball isn't in the dictionary either :(
    hewent he went
    

    Basically you need to change the code so that:

    • you add space to the alphabet to automatically explore the word breaks.
    • you first check that all of the words that make up a phrase are in the dictionary to consider the phrase valid, rather than just dictionary membership directly (the dict contains no phrases).
    • you need a way to score a phrase against plain words.

    The latter is the trickiest, and I use a braindead independence assumption for phrase composition that the probability of two adjacent words is the product of their individual probabilities (here done with sum in log prob space), with a small penalty. I am sure that in practice, you’ll want to keep some bigram stats to do that splitting well.

    import re, collections, math
    
    def words(text): return re.findall('[a-z]+', text.lower())
    
    def train(features):
      counts = collections.defaultdict(lambda: 1.0)
      for f in features:
        counts[f] += 1.0
      tot = float(sum(counts.values()))
      model = collections.defaultdict(lambda: math.log(.1 / tot))
      for f in counts:
        model[f] = math.log(counts[f] / tot)
      return model
    
    NWORDS = train(words(file('big.txt').read()))
    
    alphabet = 'abcdefghijklmnopqrstuvwxyz '
    
    def valid(w):
      return all(s in NWORDS for s in w.split())
    
    def score(w):
      return sum(NWORDS[s] for s in w.split()) - w.count(' ')
    
    def edits1(word):
      splits     = [(word[:i], word[i:]) for i in range(len(word) + 1)]
      deletes    = [a + b[1:] for a, b in splits if b]
      transposes = [a + b[1] + b[0] + b[2:] for a, b in splits if len(b)>1]
      replaces   = [a + c + b[1:] for a, b in splits for c in alphabet if b]
      inserts    = [a + c + b     for a, b in splits for c in alphabet]
      return set(deletes + transposes + replaces + inserts)
    
    def known_edits2(word):
      return set(e2 for e1 in edits1(word) for e2 in edits1(e1) if valid(e2))
    
    def known(words): return set(w for w in words if valid(w))
    
    def correct(word):
      candidates = known([word]) or known(edits1(word)) or known_edits2(word) or [word]
      return max(candidates, key=score)
    
    def t(w):
      print w, correct(w)
    
    t('expertsexchange')
    t('spel checker')
    t('spellchecker')
    t('spelchecker')
    t('baseball')
    t('hewent')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I had cause to compare Blowfish algorithms. I was comparing outputs from DI
Recently, I like using CSS-Table Layouts more and more. When I had another issue
Recently I found some simple source code of a bootloader.The following is the simple
Recently I bought a new android tablet (a no-name Chinese tablet), and I'd like
Recently I asked this question: Find Common Values in several arrays, or lists VB.NET
Recently i saw an open source javascript library have a line like : style
Recently I added to my website facebook like button, twitter follow us button and
Recently Jeff has posted regarding his trouble with database deadlocks related to reading. Multiversion
Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
Recently, I started changing some of our applications to support MS SQL Server as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.