Part 1. Getting started and making requests

By Rodrigo Alarcón, Computational Linguist

In this series of posts we want to showcase different examples on how to call our NLP API to analyze your own texts.

Getting Started

To use Codeq NLP API you need to sign up to generate a USER_ID and USER_KEY. Registration is free and we provide a developer plan with enough calls to start exploring our NLP tools.

Sign Up – Codeq Natural Language Processing API


Once you have signed up, next step would be to install our Python SDK:

Copy to Clipboard

Import the client SDK and define a pipeline

The SDK can be used to create an instance of a client using your API credentials and analyze your own documents. By default, when you call the API you will retrieve a text fully analyzed by our complete set of NLP Annotators. Or you can specify a custom pipeline depending on your needs, for example a pipeline to analyze the speech acts, sentiments and emotions of a text:

Copy to Clipboard

Analyze a text

Now you can pass a text and the pipeline you declared as input to the API client, which will return a Document object. The Document contains a list of Sentence objects with the analyzed information of the text:

Copy to Clipboard

In the last two lines, we iterate over the sentences extracted from the document and print all analyzed attributes for a quick look:

Copy to Clipboard

You can also iterate over the results and access the specific attributes of each NLP annotator. A complete list of attributes can be found in our documentation; here is an example:

Copy to Clipboard

Wich will print:

Copy to Clipboard

Analyze a list of texts (or sentences)

The client can also be used to analyze list of texts or sentences without applying any further segmentation. This will keep the original structure of your texts, which can be helpful, for example, if you’re analyzing conversations. Let’s consider the following example:

Copy to Clipboard

In this case, you just need to call the method client.analyze_sentences():

Copy to Clipboard

The output will keep the original segmentation:

Copy to Clipboard

Wrap Up

On this post we have shown how easy it is to send requests to our NLP API using our Python SDK and analyze your own texts. The following code snippet resumes the workflow explained above. Don’t forget to replace USER_ID and USER_KEY with your own API credentials.

Copy to Clipboard

Take a look at our documentation to learn more about the NLP tools we provide.

Do you need inspiration? Go to our use case demos and see how you can integrate different tools.

In our NLP demos section you can also try our tools and find examples of the output of each module.