Part-of-Speech Tag a String, Filter to Adverbs in Python

Using the Part-of-Speech (POS) tagger iterations of the Cloudmersive NLP API v2, you can break down any body of text into its various parts-of-speech in the blink of an eye. In this article we’ll cover how you can use an iteration of this API in Python to tag adverbs and return a JSON result. It’s simple and easy to do following the below steps using ready-to-run code.

Starting off you need to install the Python SDK by running the below command:

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 copy & paste the below snippet to authorize your API key (obtained by creating 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'

Finally, you can create the API class instance & call the API with the rest of the function below:

# create an instance of the API class
api_instance = cloudmersive_nlp_api_client.PosTaggerApi(cloudmersive_nlp_api_client.ApiClient(configuration))
request = cloudmersive_nlp_api_client.PosRequest() # PosRequest | Input string
try:
# Part-of-speech tag a string, filter to adverbs
api_response = api_instance.pos_tagger_tag_adverbs(request)
pprint(api_response)
except ApiException as e:
print("Exception when calling PosTaggerApi->pos_tagger_tag_adverbs: %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

Industry Use cases for Kubernetes / Openshift from Experts

DUCTF 2021 Write-ups

LeetCode Problem#163 Missing Ranges

How to convert ODP to PDF in Python

Move between View Controllers with Segues — iOS #9

RCA — Root Cause Analysis

JAVA Lambda Expression

Take control of your forms with HTML5

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

Part-of-Speech Tag a String, Filter to Nouns in Python

Easier Python Package Deploying

Flask Blueprints Tutorial

Python Unit Testing : Mock and Patch