title: how to implement python spell checker using google's "did you mean?"
body: <p>I'm looking for a way to make a function in python where you pass in a string and it returns whether it's spelled correctly. I don't want to check against a dictionary. Instead, I want it to check Google's spelling suggestions. That way, celebrity names and other various proper nouns will count as being spelled correctly.</p>
  
  <p>Here's where I'm at so far. It works most of the time, but it messes up with some celebrity names. For example, things like "cee lo green" or "posner" get marked as incorrect.</p>
  
  <pre><code>import httplib
  import xml.dom.minidom
  
  data = """
  &lt;spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1"&gt;
  &lt;text&gt; %s &lt;/text&gt;
  &lt;/spellrequest&gt;
  """
  
  def spellCheck(word_to_spell):
  
      con = httplib.HTTPSConnection("www.google.com")
      con.request("POST", "/tbproxy/spell?lang=en", data % word_to_spell)
      response = con.getresponse()
  
      dom = xml.dom.minidom.parseString(response.read())
      dom_data = dom.getElementsByTagName('spellresult')[0]
  
      if dom_data.childNodes:
          for child_node in dom_data.childNodes:
              result = child_node.firstChild.data.split()
          for word in result:
              if word_to_spell.upper() == word.upper():
                  return True;
          return False;
      else:
          return True;
  </code></pre>