Information Extraction (IE)
Information Extraction (IE) is the task of automatically pulling structured information (entities, relationships, facts) out of unstructured text. It builds directly on POS tagging, syntactic parsing, and NER from Unit 2.
Unstructured: "Riya joined Google as a Software Engineer on 5 August 2026."
Structured:
{
"person": "Riya",
"organization": "Google",
"role": "Software Engineer",
"start_date": "2026-08-05"
}
Core Sub-tasks of Information Extraction
| Sub-task | Goal | Example |
|---|---|---|
| Named Entity Recognition | Find entities (covered in Unit 2) | "Riya" = PERSON, "Google" = ORG |
| Relation Extraction | Find relationships between entities | (Riya, works_for, Google) |
| Event Extraction | Identify events and their participants/time | Event: "joining", Agent: Riya, Org: Google, Date: 5 Aug 2026 |
| Template Filling | Populate a predefined structured template | Resume parser filling {name, skills, experience} |
Relation Extraction — Rule-Based (Pattern Matching)
import re
text = "Riya works at Google. Aman is employed by Microsoft."
pattern = r'(\w+) (?:works at|is employed by) (\w+)'
matches = re.findall(pattern, text)
print(matches)
# [('Riya', 'Google'), ('Aman', 'Microsoft')]
Relation Extraction Using Dependency Parsing (Recall Unit 2)
Dependency parses expose grammatical relations (subject, object) that can be turned into (entity, relation, entity) triples.
import spacy
nlp = spacy.load("en_core_web_sm")
doc = nlp("Riya founded a startup in 2024.")
for token in doc:
if token.dep_ == "nsubj":
subject = token.text
if token.dep_ == "dobj":
obj = token.text
if token.pos_ == "VERB":
verb = token.text
print(f"({subject}, {verb}, {obj})")
# (Riya, founded, startup)
Combining NER + Pattern Matching for Structured Extraction
import spacy
import re
nlp = spacy.load("en_core_web_sm")
text = "Riya joined Google as a Software Engineer on 5 August 2026."
doc = nlp(text)
person = [ent.text for ent in doc.ents if ent.label_ == "PERSON"]
org = [ent.text for ent in doc.ents if ent.label_ == "ORG"]
date = [ent.text for ent in doc.ents if ent.label_ == "DATE"]
role_match = re.search(r'as an? ([\w\s]+?) on', text)
role = role_match.group(1) if role_match else None
record = {
"person": person[0] if person else None,
"organization": org[0] if org else None,
"role": role,
"date": date[0] if date else None
}
print(record)
# {'person': 'Riya', 'organization': 'Google', 'role': 'Software Engineer', 'date': '5 August 2026'}
Real-World Applications of Information Extraction
| Application | What is extracted |
|---|---|
| Resume/CV parsing | Skills, education, work experience, contact info |
| Legal contract analysis | Parties, obligations, dates, monetary clauses |
| Financial news monitoring | Company mentions, deal values, M&A relationships |
| Medical records | Symptoms, diagnoses, medications, dosages |
| Building a Knowledge Graph | Entity-relation-entity triples, queryable via graph databases |
Information Extraction is often the final structured output of an entire NLP pipeline — feeding chatbots, search engines, and analytics dashboards with clean, queryable facts pulled from free text.