Home SalesforceEinstein Named Entity Recognition using Salesforce Einstein API

Named Entity Recognition using Salesforce Einstein API

by Dhanik Lal Sahni
Named Entity Recognition

Named entity recognition (NER) or entity identification is an AI technique that automatically identifies named entities in given text and classifies them into predefined categories. Entities can be names of people, organizations, locations, times, quantities, monetary values, percentages, and more.

named entity recognition | salesforcecodex

Extracting these entities helps businesses easily analyze huge amounts of unstructured data, like open-ended survey responses, emails, social media conversations, and more. This extracted data contains valuable information and insights for business.

Named entity recognition has many different usage, such as text summarization, question answering or data categorization. Like to know relevant pieces of data from incoming support tickets, like company names, product names, or series numbers, making it easier to route tickets to the most suitable agent or team for handling that issue.

Salesforce Einstein API (beta) has capability to recognize named entities. In this post we will see step by step process to extract named entities from text lines.

Below steps will be required to get named entities from given text using Salesforce Einstein API.

  1. Create account in Einstein Platform Services
  2. Create Private Key and Generate Token
  3. Extract Named Entities
  4. Format response to show in LWC data table

For Step 1 and Step 2 can check our post Create OCR App using Salesforce Einstein OCR API

3. Extract Named Entities

The Einstein NER (beta) named-entity recognition (NER) model returns entities for a given text. This api right now supporting below entities

  • Datetime
  • Duration
  • Email
  • Location
  • Money
  • Number
  • Organization
  • Percent
  • Person
  • Phone-number
  • Url

For each entity, different set of information will return from API. As example, if we request entities for text ‘Marc Benioff, the CEO of Salesforce, gave the keynote speech at the conference in Paris last week.’ We will get below entities

Person : First Name : Marc , Last Name : Benioff

Organization: Salesforce

Datetime: Last week

Let us use Einstein Entity API to get entity information. Below are API request detail which need to submitted for getting entity information.

API Parameter/detailValues
Endpointhttps://api.einstein.ai/v2/language/entities
content-typemultipart/form-data; charset=”UTF-8″
Method TypePOST
AuthorizationBearer {{token}}
Cache-Controlno-cache
Bodydocument={{text}},
modelId=’ENTITIES’

For this let us create apex class EntityDetectionService to call Einstein Entity API.

Based on passed text, we will get response from API.

4. Format response to show in LWC data table

We have response text from Einstein Entity API, let us change that into tabular format. For that we have to parse JSON text into object. Create a response class to hold response data.

In step 3, we have created service class which will get entity information from passed text. Let us call that service class from controller apex class which will be called by LWC component.

Let us create a LWC component which will provide text to extract entity information. This LWC component will use EntityExtractor.getEntityText method. We can use data table component show entity information. I have used only top level information but we can get further information for each entity type like for person type we can get first name, last name etc.

Test Page:

Named Entity Recognition in Salesforce | SalesforceCodex

Reference:

https://monkeylearn.com/blog/named-entity-recognition/

Related Posts

  1. Create OCR App using Salesforce Einstein OCR API
  2. Extract Driver License Detail from Image using Einstein API
  3. Extract Text From Image using Google Cloud Vision

You may also like

1 comment

Extract Driver License Detail from Image using Einstein API | SalesforceCodex August 17, 2021 - 5:16 pm

[…] Named Entity Recognition using Salesforce Einstein API […]

Reply

Leave a Comment