Menu

How to extract entities and noun phrases from a page with Python and spaCy
📰

How to extract entities and noun phrases from a page with Python and spaCy

DEV Community: nlp·Usman Ishaq·about 15 hours ago
#wiej5f1X
#devtonlp#devto#dev#entities#self
Long article (1191 words) — no AI summary yet.
Reading 0:00
15s threshold

This script reads the visible text of a web page and lists the named entities and noun phrases that spaCy finds. It answers a practical question: which things does this page actually name, and does it name each one the same way every time?

Usman Ishaq is a semantic SEO strategist and consultant, and the founder of Digital Vikingz. The output can be compared with the entities a page should name, which is useful before writing a brief.

What do the two lists show?

In spaCy, a named entity is a real-world object with a name, such as a person, a country or a product, and the model predicts it. Noun chunks are base noun phrases: a noun plus the words that describe it. The model is statistical, so it makes mistakes, and the output is a prompt for review, not a verdict.

How do you install it?

pip install spacy python -m spacy download en_core_web_sm

Enter fullscreen mode

Exit fullscreen mode

The script was tested with Python 3.12, spaCy 3.8.18 and en_core_web_sm 3.8.0.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.