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.
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.
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.
NER is a labeling task. The basic process is:
| 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.
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:
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.
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_)
What happens here:
spacy.load loads the language model with NER capability.text to nlp processes the text: tokenization, NER, and more.doc.ents prints each found entity and its type.Sample output:
Barack Obama PERSON
Honolulu GPE
President NORP
United States GPE
GPE (Geo-Political Entity) covers locations like countries or cities.NORP is used for nationalities, religious, or political groups.You can swap in any sentence to see what entities the model detects.
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.
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.
Coming up on Day 9: Text Classification with Naive Bayes and Logistic Regression