RSS Amplifier

Data For Science · May 9, 2026

From News Articles to Knowledge Graphs with spaCy and NetworkX

0
Sign in to vote or save

Bruno Gonçalves · Data For Science

News articles encode relationships in plain language all the time… “Apple acquired Beats Electronics”, “President Obama visited France”, “Google announced a partnership with Samsung”.

Each sentence is a triple in disguise: two entities and a verb tying them together. If we extract enough of them across enough articles, we get a knowledge graph: a structure we can query, visualize, and reason over.

This post walks through that pipeline end-to-end. We start from raw news text, run named entity recognition with spaCy, infer relationships, and analyze the resulting graph.

As always, you can find the companion notebook on the Graphs for Data Science GitHub repository:

Graphs For Science GitHub

We use the AG News corpus, 120,000 articles across four categories (World, Sports, Business, Sci/Tech). For the sake of expediency, we sample 2,000 articles, balanced 500 per category. Loading is a single call to Hugging Face:

Read the original on data4sci.substack.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.