Previously, on Day 7: Explained part-of-speech (POS) tagging, its importance in NLP, different approaches to tagging, common tagsets, and typical challenges such as ambiguity and unknown words.


What Is Named Entity Recognition (NER)?

Named Entity Recognition (NER) is a core task in Natural Language Processing (NLP). Its purpose is to find and label words or phrases in text that refer to specific "named entities." A named entity is any real-world object with a distinct name. In practice, this means people, companies, locations, dates, money amounts, product names, and more.

For example, when you read a news article, you can immediately spot terms like “Barack Obama,” “United Nations,” or “Monday, July 10.” NER lets computers do the same thing. It marks these phrases so that downstream programs know they refer to specific, meaningful things in the real world. This is foundational for many NLP tasks; knowing "who," "where," and "when" unlocks advanced automation and insight from raw text.

Common Types of Named Entities

Most NER systems look for a standard set of categories, but the specifics can change depending on the tool or domain. Here are the most common named entity types, with examples:

Some systems recognize more detailed categories, such as Money (“$100”), Percentages (“55%”), or Products. The core idea is the same: identify and label text that names a unique, real-world object.

How NER Works: High-Level Process

NER is a labeling task. The basic process is:

  1. Tokenization: The text is split into tokens. A token is usually a word or punctuation mark. (Recall tokenization from earlier lessons on preprocessing.)
  2. Label Assignment: Each token (or sometimes a complete phrase) gets a label for its entity type—if any. For example, in the sentence “Apple launched a new product in California”:

| Token | Label |
|-----------|------------|
| Apple | ORG |
| launched | O (None) |
| a | O |
| new | O |
| product | O |
| in | O |
| California| LOC |

This format is similar to Part-of-Speech (POS) tagging, but instead of grammatical roles, the labels mark entity types.

Simple Rule-Based NER

Early NER systems were rule-based, built from patterns or lists. Two basic techniques:

Example rule for person names:

If a word is capitalized and appears in a list of person names, tag it as PERSON.

Strengths:

Limitations:

Statistical and Machine Learning-Based NER

Modern NER uses machine learning. Instead of hand-coding rules, we train models on labeled examples. The model learns to predict, for each token, the correct entity label.

NER here is a sequence labeling problem—just like POS tagging (reviewed previously). Each word in a sentence receives a tag such as:

Popular algorithms include:

Because these models train on thousands or millions of sentences, they can catch subtleties that rules miss—like context or edge cases. They are also much more robust to new data and rare phrases.

NER in Practice: Minimal Code Example

Here’s a real NER example using spaCy, a popular Python NLP library with a built-in English model:

import spacy

# Load the English NER model. If needed: python -m spacy download en_core_web_sm
nlp = spacy.load("en_core_web_sm")

text = "Barack Obama was born in Honolulu and served as President of the United States."

doc = nlp(text)

for ent in doc.ents:
    print(ent.text, ent.label_)
Enter fullscreen mode Exit fullscreen mode

What happens here:

Sample output:

Barack Obama PERSON
Honolulu GPE
President NORP
United States GPE
Enter fullscreen mode Exit fullscreen mode

You can swap in any sentence to see what entities the model detects.

Applications and Challenges of NER

NER in the Real World

Real-World Challenges

NER is not perfect—handling ambiguity, change, and domain-specific language remains hard. But even a basic NER pipeline brings order to messy text, extracting structure that downstream software can use. The next steps in NLP will show how NER becomes more powerful when combined with context and larger language models.


Key Takeaways

Try It Yourself

Choose a short news paragraph or sentence and process it using spaCy's NER tool or an online NER demo. Write down all entities detected and their types. Then, check the text yourself for any missed or misclassified entities and briefly reflect on possible reasons the NER tool struggled with those cases.

Further Resources


Coming up on Day 9: Text Classification with Naive Bayes and Logistic Regression