Find Spelling Corrections in Python

No matter how much time we spend writing and posting papers, blogs, etc., spelling every word correctly is still a tall task. Thankfully, NLP makes it possible to find spelling correction suggestions for any given word and quickly return those results. The Cloudmersive NLP API v2 has a Spellcheck iteration which can add this NLP functionality to your application. Let’s run through how you can use it in Python.

You can begin by installing the Python SDK using the below snippet:

pip install cloudmersive-nlp-api-clientfrom __future__ import print_function
import time
import cloudmersive_nlp_api_client
from cloudmersive_nlp_api_client.rest import ApiException
from pprint import pprint

After that, you can add in code to authorize our API key for access (this key can be obtained by making a free account on the Cloudmersive website):

# Configure API key authorization: Apikey
configuration = cloudmersive_nlp_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'

For your last step, simply copy in the rest of the callback function below & you’re all set:

# create an instance of the API class
api_instance = cloudmersive_nlp_api_client.SpellcheckApi(cloudmersive_nlp_api_client.ApiClient(configuration))
value = cloudmersive_nlp_api_client.CheckWordRequest() # CheckWordRequest | Input string
try:
# Find spelling corrections
api_response = api_instance.spellcheck_correct_json(value)
pprint(api_response)
except ApiException as e:
print("Exception when calling SpellcheckApi->spellcheck_correct_json: %s\n" % e)

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Numpy Tutorial — 1: Beginners Guide to Data Analysis

How to Convert JSON to XML in Python

Contest Logging Software For Mac

Top 10 Bugs Found in C++ Projects in 2020

How you can point your Google domain to an S3 bucket

Securing Spring boot apps with Basic Auth and Keycloak

Coroutines with Unity

Character Controller — Part 1: Project setup

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
Cloudmersive

Cloudmersive

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

More from Medium

Check if Sentence is Spelled Correctly in Python

Python — Software required for NLP programming

How to Automate Machine Learning with Images

5 Lesser-Known Python Libraries for Your Next NLP Project

Hidden gem