Custom Natural Language Processing from Google Sheets in two easy steps

Custom Natural Language Processing from Google Sheets in two easy steps

Note: the Google Sheets Add-on is now deprecated, but you can replicate most of its functionality with some code you can copy and paste from here.

Custom language models allow users to leverage tailor-made Natural Language Processing to understand textual content. These models allow businesses to build innovative solutions that use the insights they extract, and analysts to automatically discover trends that they are interested in.

Our Text Analysis Platform (TAP) allows you to do exactly this. With TAP, you can build, tweak, deploy and use, custom language models, all from within your browser. TAP simplifies the complex task of building, testing and deploying custom NLP models and greatly reduces the build time from days to minutes.

To make this process even more simple, we’ve put together a Google Sheets script to query TAP models from every analyst’s favourite tool – a spreadsheet. By simply copying and pasting this script into Google Sheets, you can get started extracting insights from custom NLP models in a matter of minutes.

For the rest of this post, we’re going to walk you through the three easy steps to do this. To follow along, you’ll need to have:

  • The API key for a custom model you’ve built in TAP.
  • A dataset of text samples you want to query with a custom model (in this example we’re using Tweets).

TAP is currently in Beta, so you can build, tweak, and deploy custom models for free – you can sign up here and check out the pricing for queries here.

First, what is a custom Natural Language Processing model?

Standard Natural Language Processing models are built for standard use cases – for example, they allow users to classify subjects according to standard taxonomies, or use sentiment analysis model built for use in every industry. But custom models allow users to classify subjects based on a list of categories that they have come up with themselves, or build sentiment analysis models tailored to a specific industry or use case.

The custom model we’re using in this blog predicts whether a piece of text it is shown is offensive or not, but you can train a custom models to classify a vast amount of things. For example, you can build one to classify what team in your company a review or question pertains to, to understand what subjects are being talked about in a document, or even to fine-tune a sentiment analysis model to a particular industry.

Using the following script, you can now put any of the vast amount of use cases into practice on Google Sheets.

Step 1: Copy & paste this script into Script Editor

With the text you want to analyze open in Google Sheets, navigate to the Script Editor on the Tools dropdown menu.


Once the Script Editor is open, delete the existing text and then copy and paste this script, and then add in your TAP API key, which you can get on the page of your Model within TAP. After you have done this, save the project as ‘TAPResults’


Step 2: Enter this text into your spreadsheet & hit enter

After saving the script in Script Editor, go back to your spreadsheet and paste the following formula into the cell next to the first cell you want to analyze:

=TAPResults(A1, "YOUR_MODEL_ID", 1)

The cell number (A1 in the example above) should point to the cell that contains the text on the same row – so if you have a header in your spreadsheet and you have pasted the text above into B2 instead of B1, change the A1 above to A2 (to make sure the script will analyze the right cell). Also, because of formatting issues, sometimes you might need to manually type the quotation marks next to your model ID (Google Sheets might not recognize pasted quotation marks and will return an error).

Be sure to enter the ID of your model were the placeholder is, like we did in the previous step (you can find the model ID number on the model’s page – it’s the string of letters and numbers at on your model’s URL after “models/”).

After you have entered this text, you will see that it queries the model instantly. To analyze the rest of the column, select the cell you entered your formula into and extend it down the column. After you do this, you will see the results from TAP populating the cells.


If you have text that you would like to analyze with a custom model, sign up below to get your login credentials for TAP.  Sign up to the Beta plan where you can build, tweak, and deploy you model all for free!

Text Analysis Platform

Let's Talk