How to Spellcheck a Sentence in Python

Spellcheck is one of the most common and important features out there, but it is also one of the most aggravating to create yourself. If you will allow me to spare you from the tedium, I can show you an incredibly easy way to implement this feature into your project with essentially no effort whatsoever. Sound good? Keep reading.

We will be using an API to get this job done for us, so let’s start out by installing its client now.

pip install git+

Our API contains a function called spell_check_check_sentence_string, which we can access via an API key. The below example demonstrates how to set that up.

from __future__ import print_functionimport timeimport cloudmersive_nlp_api_clientfrom import ApiExceptionfrom pprint import pprint# Configure API key authorization: Apikeyconfiguration = cloudmersive_nlp_api_client.Configuration()configuration.api_key['Apikey'] = 'YOUR_API_KEY'# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['Apikey'] = 'Bearer'# create an instance of the API classapi_instance = cloudmersive_nlp_api_client.SpellCheckApi(cloudmersive_nlp_api_client.ApiClient(configuration))value = 'value_example' # str | Input sentence wordtry:# Spell check a sentenceapi_response = api_instance.spell_check_check_sentence_string(value)pprint(api_response)except ApiException as e:print("Exception when calling SpellCheckApi->spell_check_check_sentence_string: %s\n" % e)

Done. See how easy an API can make your life? This library also has spellcheck for individual words, and a number of functions related to Natural Language Processing.

Image for post
Image for post

Written by

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store