How to parse an Unstructured International Address in Node.JS using NLP

Any time you deal with user submitted mailing addresses, there will always loom the irritating specter of improper address formatting. This is guaranteed to throw a wrench in your works, whether it’s product shipping, mass mailing, etc. That’s why we are going to use Natural Language Processing (NLP) to automatically sort unstructured address strings into their proper format. To make things even better, we’ve already done all the work for you, so all that’s required from you is to follow a couple of simple steps.

Step one, install the API client:

npm install cloudmersive-validate-api-client --save

Step two, call the desired function:

var CloudmersiveValidateApiClient = require('cloudmersive-validate-api-client');var defaultClient = CloudmersiveValidateApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveValidateApiClient.AddressApi();var input = new CloudmersiveValidateApiClient.ParseAddressRequest(); // ParseAddressRequest | Input parse requestvar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.addressParseString(input, callback);

And we are already done. Enter any garbled address and marvel as the API returns it in perfect formatting.

Image for post
Image for post

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