Extract Sentences from a String in Python
In this article, we’re going to walk through how you can connect to another one of Cloudmersive’s NLP API v2 iterations. This one is a big help for breaking down large chunks of text — the /nlp-v2/segmentation/sentences iteration takes an input string and breaks it into separate sentences, providing results in a string once again. Let’s take a look at how you can easily connect in Python.
The first step of the process is to run the Python SDK installation command & copy the rest of the code below:
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 the below snippet & input your API key:
# Configure API key authorization: Apikey
configuration = cloudmersive_nlp_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
Finally, you can complete the function with the following code, and you’re all set to go:
# 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.CheckSentenceRequest() # CheckSentenceRequest | Input sentencetry:
# Check if sentence is spelled correctly
api_response = api_instance.spellcheck_check_sentence(value)
pprint(api_response)
except ApiException as e:
print("Exception when calling SpellcheckApi->spellcheck_check_sentence: %s\n" % e)