Tutorial

How to Extract Custom Entities in Text Content with JavaScript?

This tutorial shows you how to implement Custom Named Entity Recognition (NER) using JavaScript and Eden AI’s API. Learn how to extract specific entities from text based on your needs, with a step-by-step guide, code example, and output explanation.

How to Extract Custom Entities in Text Content with JavaScript?

In this tutorial, you’ll learn how to use the Custom Named Entity Recognition API with Javascript in just 5 minutes. Eden AI offers a simple, developer-friendly interface to extract specific entities from text effortlessly.

What is Custom Named Entity Recognition API?

Custom Named Entity Recognition (NER) API is a tool that enables users to build and deploy their own models for recognizing and extracting named entities from text such as names of people, organizations, locations, dates, or any other custom-defined categories.

A Custom NER API enables users to train models with their own labeled data, specifying the exact entities they want to extract.

This approach offers more precise and domain-specific entity recognition tailored to specific industries or use cases.

After training, developers can easily integrate the custom NER capabilities into their applications through the API.

How to Extract Custom Entities in Text Content?

Get Access to Eden AI API

1. Sign up: Create an account on Eden AI and obtain your API key. This key will give you access to a wide range of AI services including Custom Named Entity Recognition.

2. Access Text Processing: Once you're logged in, navigate to the Text section of the Eden AI platform to explore the available tools and features.

3. Choose Custom Named Entity Recognition: Click on the Custom Named Entity Recognition feature.

Implementing the Feature in JavaScript

Install JavaScript Requests Module

For this tutorial, we’ll use axios, a promise-based HTTP client for Node.js. To install it, run:


npm install axios

Prepare the Code

Here’s a working example of how to use the Eden AI Custom Named Entity Recognition API in JavaScript:


const axios = require("axios").default;

const options = {
  method: "POST",
  url: "https://api.edenai.run/v2/text/custom_named_entity_recognition",
  headers: {
    authorization: "Bearer YOUR_API_KEY_HERE", // Replace with your actual API key
  },
  data: {
    providers: "openai", // You can also test other providers on Eden AI
    text: "I was born in Lyon in February 1996",
    entities: ["person", "date"] // Define the custom entities you want to extract
  }
};

axios
  .request(options)
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.error(error);
  });

Code Explanation

  • url: The endpoint for Eden AI’s Custom NER API.
  • authorization: The Bearer token (your API key).
  • text: The input string to analyze.
  • entities: A list of custom entities you want the model to detect (e.g., person, date).

Example Output

A sample response might look like this:


{
  "openai": {
    "entities": [
      { "entity": "Lyon", "category": "location", "start": 16, "end": 20 },
      { "entity": "February 1996", "category": "date", "start": 24, "end": 38 }
    ],
    "status": "success"
  }
}

Explanation:

  • entities: An array of extracted items, each with:
    • entity: The detected string.
    • category: The category label you defined (e.g., "date").
    • start and end: Character index positions in the original text.
  • status: Indicates if the operation was successful.

Why Eden AI is the Best Tool for Custom Named Entity Recognition

Multi-provider Access

Test and use top AI models (like OpenAI, Google, Amazon, etc.) from a single API.

Customizability

Easily define the entities that matter to your domain.

Cost-Efficient

Pay-as-you-go pricing and cost-optimization by comparing multiple provider results.

Developer-Friendly

Clean JSON responses and easy integration with most languages, including JavaScript.

Conclusion

With just a few lines of JavaScript and Eden AI’s powerful API, you can implement a Custom NER system that fits your exact needs.

Whether you're working on content moderation, business automation, or intelligent search, this feature saves you time and boosts accuracy.

Eden AI simplifies complex AI integration, letting you focus on building great user experiences.

Try it today and unlock the full potential of your text data with custom entity extraction!

Start Your AI Journey Today

  • Access 100+ AI APIs in a single platform.
  • Compare and deploy AI models effortlessly.
  • Pay-as-you-go with no upfront fees.
Start building FREE

Related Posts

Try Eden AI for free.

You can directly start building now. If you have any questions, feel free to chat with us!

Get startedContact sales
X

Start Your AI Journey Today

Sign up now with free credits to explore 100+ AI APIs.
Get my FREE credits now