Parse an Unstructured Input Text String into an International, Formatted Address in Python

In this article, we’re going to walk through using a useful iteration of Cloudmersive’s Validate API in Python. The /validate/address/parse iteration uses Machine Learning (ML) & Natural Language Processing (NLP) to parse an unstructured input text string into an international, formatted address. This iteration can handle a wide variety of cases, which includes non-standard and unstructured address strings across a wide array of countries and address-formatting norms. Connecting is made easy with ready-to-run code and extensive documentation for your convenience.

To use this API, first install the Python SDK with the below command:

pip install cloudmersive-validate-api-clientfrom __future__ import print_function
import time
import cloudmersive_validate_api_client
from cloudmersive_validate_api_client.rest import ApiException
from pprint import pprint

After that, you’ll need to authorize your API key with the below snippet. If you don’t have a key already, you can get one by creating a free account on the Cloudmersive website.

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

You can then complete the function by copying & pasting the below code:

# create an instance of the API class
api_instance = cloudmersive_validate_api_client.AddressApi(cloudmersive_validate_api_client.ApiClient(configuration))
input = cloudmersive_validate_api_client.ParseAddressRequest() # ParseAddressRequest | Input parse request
try:
# Parse an unstructured input text string into an international, formatted address
api_response = api_instance.address_parse_string(input)
pprint(api_response)
except ApiException as e:
print("Exception when calling AddressApi->address_parse_string: %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

How To Create Expansion Panel List In Flutter

What is Normalization in DBMS & its form? explain in details with example

Using Dolly Track in Unity

How to Explain Source Code to Business Stakeholders?

100 Days of Swift — Consolidation IV

You Won’t Believe These 5 Hilarious Programming Languages Actually Exist

Buffer overflow tutorial (part 3)

Flutter Bloc State Management

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

Parse & Validate a Full Name in Python

Python Basic Operations

Benefits of Using Python for Software Development

Python for Beginners🐍 By Ansh Sharma