Implement the Azure Text Analytics Service - 1
Create your REST API using the Azure Text Analytics Service.
We'll cover the following
Create a virtual environment for our API
We have already discussed how to create a virtual environment using Anaconda as well as the venv
Python package. Before starting this project, it is advisable to create a virtual environment and activate it.
In this project, we will not use any
async
functionality for the sake of understanding the normalAPI
building. Although, if you want, you can go ahead with theasync
functionality that we have already discussed.
Create the call_text_analytics_api
function
We will first create a function call_text_analytics_api()
that will accept three parameters:
- Header data: This contains our key for the text analytics service.
- Document: This contains the text data in the format which is acceptable by the text analytics service. (Remember, we discussed the format of the data that has to be sent to the service in the previous lesson).
- Endpoint: This will contain either
sentiment
orkeyPhrases
, telling the service to perform the respective operation on our text data.You can have the following values of
endpoint
to perform other operations on your text data:languages
: This will be used to detect the language in the text.entities/recognition/general
: This will perform general Named Entity Recognition from your text data.entities/recognition/pii
: This will extract Personally Identifiable Information (PII) from the text. The PII feature is part of NER, and it can identify sensitive entities in the text that are associated with an individual person such as a phone number, email address, mailing address, or passport number.
Let us now create our function.
Get hands-on with 1200+ tech skills courses.