Photo by
DALL•E

How to Identify Names, Organizations, and Places in Text

Highlight on the Names Skill

Yael Kurz
Yael Kurz
·
Oct 19, 2022
·
3 min read

For a human, identifying entities such as names & locations in text is a simple task. But writing a script that does this automatically is very challenging.

In 5 minutes of reading you’ll learn how to identify named entities in any text, audio, or video: 

People👩🏽‍💻 Groups🦸🏾‍♂️ Organizations🏬
Developers, celebs, commoners,.. Canadians,engineers,superheroes .. Companies, agencies, institutions, ..
Events📅 Places & locations🗺️ Works of art🖼️
Concerts, Wars, Hurricanes, ... Countries, buildings, airports, .. Books, movies, songs, ..
Products/Services📦 Languages💬 Laws⚖️
Dog walker, IBM, iPhone, .. English, Italian, Klingon, .. Fair Housing Act, 2021 H 454, ..

Before we implement this in our code let's give it a run in the studio.

For example, we’ll analyze this segment from Star Wars:

Here I uploaded it into the Language Studio and analyzed it with the Names Skill:

As we can see, the Skill extracted all the names as well as where they appear in the text.

For some entities, the Skill will provide extra information, such as the full name & entity type,  based on the context. In this example your can see how it converts “NYC” to “New York City”, and identifies it as a “Location: City”:

To use this in our code, we can now choose the framework we need and copy the generated API call:

As you can see, with one simple API call we can get the names that appear in a text. This can a powerful tool to have in your developer toolbox. 

Let's try out some more complex examples to show how powerful this tool can be.

First , we'll run this on this article by using the html to article skill and then the names skill.

You can go to the studio directly and see for yourself

Another example will be this article. You can try this for yourself.

As you can see, the options are endless. I bet you already have some cool ideas for applications using this tool alone. 

Code examples

Python

```

# pip install oneai

import oneai

oneai.api_key = "<YOUR-API-KEY>"

text = "I live in springfield and work at the nuclear plant"

pipeline = oneai.Pipeline(

  steps = [

oneai.skills.Names(),

  ]

)

output = pipeline.run(text)

```

Node.js

```

// npm install oneai

const OneAI = require("oneai");

// ES6: import OneAI from "oneai";

const oneai = new OneAI("<YOUR-API-KEY>");

const text = "I live in springfield and work at the nuclear plant";

const pipeline = new oneai.Pipeline(

oneai.skills.names(),

);

pipeline

  .run(text)

  .then((output) => console.log(output))

  .catch((error) => console.error(error));

```