• About
  • Advertise
  • Privacy & Policy
  • Contact
Ai News
Advertisement
  • Home
    • Home – Layout 1
    • Home – Layout 2
    • Home – Layout 3
    • Home – Layout 4
    • Home – Layout 5
    • Home – Layout 6
  • News
    • All
    • Business
    • Politics
    • Science
    • World
    Hillary Clinton in white pantsuit for Trump inauguration

    Hillary Clinton in white pantsuit for Trump inauguration

    Amazon has 143 billion reasons to keep adding more perks to Prime

    Amazon has 143 billion reasons to keep adding more perks to Prime

    Shooting More than 40 Years of New York’s Halloween Parade

    Shooting More than 40 Years of New York’s Halloween Parade

    These Are the 5 Big Tech Stories to Watch in 2017

    These Are the 5 Big Tech Stories to Watch in 2017

    Why Millennials Need to Save Twice as Much as Boomers Did

    Why Millennials Need to Save Twice as Much as Boomers Did

    Doctors take inspiration from online dating to build organ transplant AI

    Doctors take inspiration from online dating to build organ transplant AI

    Trending Tags

    • Trump Inauguration
    • United Stated
    • White House
    • Market Stories
    • Election Results
  • Tech
    • All
    • Apps
    • Gadget
    • Mobile
    • Startup
    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    Shadow Tactics: Blades of the Shogun Review

    Shadow Tactics: Blades of the Shogun Review

    macOS Sierra review: Mac users get a modest update this year

    macOS Sierra review: Mac users get a modest update this year

    Hands on: Samsung Galaxy A5 2017 review

    Hands on: Samsung Galaxy A5 2017 review

    The Last Guardian Playstation 4 Game review

    The Last Guardian Playstation 4 Game review

    These Are the 5 Big Tech Stories to Watch in 2017

    These Are the 5 Big Tech Stories to Watch in 2017

    Trending Tags

    • Nintendo Switch
    • CES 2017
    • Playstation 4 Pro
    • Mark Zuckerberg
  • Entertainment
    • All
    • Gaming
    • Movie
    • Music
    • Sports
    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    macOS Sierra review: Mac users get a modest update this year

    macOS Sierra review: Mac users get a modest update this year

    Hands on: Samsung Galaxy A5 2017 review

    Hands on: Samsung Galaxy A5 2017 review

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Harnessing the power of VR with Power Rangers and Snapdragon 835

    Harnessing the power of VR with Power Rangers and Snapdragon 835

    So you want to be a startup investor? Here are things you should know

    So you want to be a startup investor? Here are things you should know

  • Lifestyle
    • All
    • Fashion
    • Food
    • Health
    • Travel
    Shooting More than 40 Years of New York’s Halloween Parade

    Shooting More than 40 Years of New York’s Halloween Parade

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Why Millennials Need to Save Twice as Much as Boomers Did

    Why Millennials Need to Save Twice as Much as Boomers Did

    Doctors take inspiration from online dating to build organ transplant AI

    Doctors take inspiration from online dating to build organ transplant AI

    How couples can solve lighting disagreements for good

    How couples can solve lighting disagreements for good

    Ducati launch: Lorenzo and Dovizioso’s Desmosedici

    Ducati launch: Lorenzo and Dovizioso’s Desmosedici

    Trending Tags

    • Golden Globes
    • Game of Thrones
    • MotoGP 2017
    • eSports
    • Fashion Week
  • Review
    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    Shadow Tactics: Blades of the Shogun Review

    Shadow Tactics: Blades of the Shogun Review

    macOS Sierra review: Mac users get a modest update this year

    macOS Sierra review: Mac users get a modest update this year

    Hands on: Samsung Galaxy A5 2017 review

    Hands on: Samsung Galaxy A5 2017 review

    The Last Guardian Playstation 4 Game review

    The Last Guardian Playstation 4 Game review

    Intel Core i7-7700K ‘Kaby Lake’ review

    Intel Core i7-7700K ‘Kaby Lake’ review

No Result
View All Result
  • Home
    • Home – Layout 1
    • Home – Layout 2
    • Home – Layout 3
    • Home – Layout 4
    • Home – Layout 5
    • Home – Layout 6
  • News
    • All
    • Business
    • Politics
    • Science
    • World
    Hillary Clinton in white pantsuit for Trump inauguration

    Hillary Clinton in white pantsuit for Trump inauguration

    Amazon has 143 billion reasons to keep adding more perks to Prime

    Amazon has 143 billion reasons to keep adding more perks to Prime

    Shooting More than 40 Years of New York’s Halloween Parade

    Shooting More than 40 Years of New York’s Halloween Parade

    These Are the 5 Big Tech Stories to Watch in 2017

    These Are the 5 Big Tech Stories to Watch in 2017

    Why Millennials Need to Save Twice as Much as Boomers Did

    Why Millennials Need to Save Twice as Much as Boomers Did

    Doctors take inspiration from online dating to build organ transplant AI

    Doctors take inspiration from online dating to build organ transplant AI

    Trending Tags

    • Trump Inauguration
    • United Stated
    • White House
    • Market Stories
    • Election Results
  • Tech
    • All
    • Apps
    • Gadget
    • Mobile
    • Startup
    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    Shadow Tactics: Blades of the Shogun Review

    Shadow Tactics: Blades of the Shogun Review

    macOS Sierra review: Mac users get a modest update this year

    macOS Sierra review: Mac users get a modest update this year

    Hands on: Samsung Galaxy A5 2017 review

    Hands on: Samsung Galaxy A5 2017 review

    The Last Guardian Playstation 4 Game review

    The Last Guardian Playstation 4 Game review

    These Are the 5 Big Tech Stories to Watch in 2017

    These Are the 5 Big Tech Stories to Watch in 2017

    Trending Tags

    • Nintendo Switch
    • CES 2017
    • Playstation 4 Pro
    • Mark Zuckerberg
  • Entertainment
    • All
    • Gaming
    • Movie
    • Music
    • Sports
    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    macOS Sierra review: Mac users get a modest update this year

    macOS Sierra review: Mac users get a modest update this year

    Hands on: Samsung Galaxy A5 2017 review

    Hands on: Samsung Galaxy A5 2017 review

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Harnessing the power of VR with Power Rangers and Snapdragon 835

    Harnessing the power of VR with Power Rangers and Snapdragon 835

    So you want to be a startup investor? Here are things you should know

    So you want to be a startup investor? Here are things you should know

  • Lifestyle
    • All
    • Fashion
    • Food
    • Health
    • Travel
    Shooting More than 40 Years of New York’s Halloween Parade

    Shooting More than 40 Years of New York’s Halloween Parade

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Why Millennials Need to Save Twice as Much as Boomers Did

    Why Millennials Need to Save Twice as Much as Boomers Did

    Doctors take inspiration from online dating to build organ transplant AI

    Doctors take inspiration from online dating to build organ transplant AI

    How couples can solve lighting disagreements for good

    How couples can solve lighting disagreements for good

    Ducati launch: Lorenzo and Dovizioso’s Desmosedici

    Ducati launch: Lorenzo and Dovizioso’s Desmosedici

    Trending Tags

    • Golden Globes
    • Game of Thrones
    • MotoGP 2017
    • eSports
    • Fashion Week
  • Review
    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    Shadow Tactics: Blades of the Shogun Review

    Shadow Tactics: Blades of the Shogun Review

    macOS Sierra review: Mac users get a modest update this year

    macOS Sierra review: Mac users get a modest update this year

    Hands on: Samsung Galaxy A5 2017 review

    Hands on: Samsung Galaxy A5 2017 review

    The Last Guardian Playstation 4 Game review

    The Last Guardian Playstation 4 Game review

    Intel Core i7-7700K ‘Kaby Lake’ review

    Intel Core i7-7700K ‘Kaby Lake’ review

No Result
View All Result
Ai News
No Result
View All Result
Home Machine Learning

Mastering NLP with spaCy – Part 2

AiNEWS2025 by AiNEWS2025
2025-08-02
in Machine Learning
0
Mastering NLP with spaCy – Part 2
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter


in a sentence provide a lot of information, such as what they mean in the real world, how they connect to other words, how they change the meaning of other words, and sometimes their true meaning can be ambiguous, and can even confuse humans!

Image via Unsplash

All of this must be figured out to build applications with Natural Language Understanding capabilities. Three main tasks help to capture different kinds of information from text:

  • Part-of-speech (POS) tagging
  • Dependency parsing
  • Named entity recognition

Part of Speech (POS) Tagging

Image by Author

In POS tagging, we classify words under certain categories, based on their function in a sentence. For example we want to differentiate a noun from a verb. This can help us understand the meaning of some text.

The most common tags are the following.

  • NOUN: Names a person, place, thing, or idea (e.g., “dog”, “city”).
  • VERB: Describes an action, state, or occurrence (e.g., “run”, “is”).
  • ADJ: Modifies a noun to describe its quality, quantity, or extent (e.g., “big”, “happy”).
  • ADV: Modifies a verb, adjective, or other adverb, often indicating manner, time, or degree (e.g., “quickly”, “very”).
  • PRON: Replaces a noun or noun phrase (e.g., “he”, “they”).
  • DET: Introduces or specifies a noun (e.g., “the”, “a”).
  • ADP: Shows the relationship of a noun or pronoun to another word (e.g., “in”, “on”).
  • NUM: Represents a number or quantity (e.g., “one”, “fifty”).
  • CONJ: Connects words, phrases, or clauses (e.g., “and”, “but”).
  • PRT: A particle, often part of a verb phrase or preposition (e.g., “up” in “give up”).
  • PUNCT: Marks punctuation symbols (e.g., “.”, “,”).
  • X: Catch-all for other or unclear categories (e.g., foreign words, symbols).

These are called Universal Tags. Then each language can have more granular tags. For example we can expand the “noun” tag to add the singular/plural information etc.

In spaCy tags are represented with acronyms like “VBD”. If you are not sure what an acronym refers to, you can ask spaCy to explain with spacy.explain()

Let’s see some examples.

import spacy 
spacy.explain("VBD")

>>> verb, past tense

Let’s try now to investigate the POS tags of an entire sentence

nlp = spacy.load("en_core_web_sm")
doc = nlp("I love Rome, it is the best city in the world!"
)
for token in doc:
    print(f"{token.text} --> {token.tag_}--> {spacy.explain(token.tag_)}")
Image by Author

The tag of a word depends on the words nearby, their tags, and the word itself.

POS taggers are based on statistical models. We have mainly

  • Rule-Based Taggers: Use hand-crafted linguistic rules (e.g., “a word after ‘the’ is often a noun”).
  • Statistical Taggers: Use probabilistic models like Hidden Markov Models (HMMs) or Conditional Random Fields (CRFs) to predict tags based on word and tag sequences.
  • Neural Network Taggers: Use deep learning models like Recurrent Neural Networks (RNNs), Long Short-Term Memory (LSTM) networks, or Transformers (e.g., BERT) to capture context and predict tags.

Dependency Parsing

With POS tagging we are able to categorize the words in out document, but we don’t know what are the relationships among the words. This is exactly what dependency parsing does. This helps us understand the structure of a sentence.

We can think a dependency as a direct edge/link that goes from a parent word to a child, which defines the relationship between the two. This is why we use dependency trees to represent the structure of sentences. See the following image.

src: https://spacy.io/usage/visualizers

In a dependency relation, we always have a parent, also called the head, and a dependent, also called the child. In the phrase “red car”, car is the head and red is the child.

Image by Author

In spaCy the relation is always assigned to the child and can be accessed with the attribute token.dep_

doc = nlp("red car")

for token in doc:
    print(f"{token.text}, {token.dep_} ")

>>> red, amod 
>>> car, ROOT 

As you can see in a sentence, the main word, usually a verb, in this case a noun, has the role of ROOT. From the root, we build our dependency tree.

It is important to know, also that a word can have multiple children but only one parent.

So in this case what does the amod relationship tells us?

The relation applies whether the meaning of the noun is modified in a compositional way (e.g., large house) or an idiomatic way (hot dogs).

Indeed, the “red” is a word that modifies the word “car” by adding some information to it.

I will list now the most fundamental relationship you can find in a dependency parsing and their meaning.

Fot a comprehensive list check this website: https://universaldependencies.org/u/dep/index.html

  • root
    • Meaning: The main predicate or head of the sentence, typically a verb, anchoring the dependency tree.
    • Example: In “She runs,” “runs” is the root.
  • nsubj (Nominal Subject)
    • Meaning: A noun phrase acting as the subject of a verb.
    • Example: In “The cat sleeps,” “cat” is the nsubj of “sleeps.”
  • obj (Object)
    • Meaning: A noun phrase directly receiving the action of a verb.
    • Example: In “She kicked the ball,” “ball” is the obj of “kicked.”
  • iobj (Indirect Object)
    • Meaning: A noun phrase indirectly affected by the verb, often a recipient.
    • Example: In “She gave him a book,” “him” is the iobj of “gave.”
  • obl (Oblique Nominal)
    • Meaning: A noun phrase acting as a non-core argument or adjunct (e.g., time, place).
    • Example: In “She runs in the park,” “park” is the obl of “runs.”
  • advmod (Adverbial Modifier)
    • Meaning: An adverb modifying a verb, adjective, or adverb.
    • Example: In “She runs quickly,” “quickly” is the advmod of “runs.”
  • amod (Adjectival Modifier)
    • Meaning: An adjective modifying a noun.
    • Example: In “A red apple,” “red” is the amod of “apple.”
  • det (Determiner)
    • Meaning: A word specifying the reference of a noun (e.g., articles, demonstrations).
    • Example: In “The cat,” “the” is the det of “cat.”
  • case (Case Marking)
    • Meaning: A word (e.g., preposition) marking the role of a noun phrase.
    • Example: In “In the park,” “in” is the case of “park.”
  • conj (Conjunct)
    • Meaning: A coordinated word or phrase linked via a conjunction.
    • Example: In “She runs and jumps,” “jumps” is the conj of “runs.”
  • cc (Coordinating Conjunction)
    • Meaning: A conjunction linking coordinated elements.
    • Example: In “She runs and jumps,” “and” is the cc.
  • aux (Auxiliary)
    • Meaning: An auxiliary verb supporting the main verb (tense, mood, aspect).
    • Example: In “She has eaten,” “has” is the aux of “eaten.”

We can visualize the dependency tree in spaCy using the display module. Let’s see an example.

from spacy import displacy

sentence = "A dependency parser analyzes the grammatical structure of a sentence."

nlp = spacy.load("en_core_web_sm")
doc = nlp(sentence)

displacy.serve(doc, style="dep")
Image by Author

Named Entity Recognition (NER)

A POS tag provides with information about the role of a word in a sentence. When we perform NER we look for words that represent objects in the real world: a company name, a proper name, a location etc.

We refer to these words as named entity. See this example.

src: https://spacy.io/usage/visualizers#ent

In the sentence “Rome is the capital of Italy“, Rome and Italy are named entity, while capital it’s not because it is a generic noun.

spaCy supports many named entities already, to visualise them:

nlp.get_pipe("ner").labels

Named entity are accessible in spaCy with the doc.ents attribute

sentence = "A dependency parser analyzes the grammatical structure of a sentence."

nlp = spacy.load("en_core_web_sm")
doc = nlp("Rome is the bast city in Italy based on my Google search")

doc.ents

>>> (Rome, Italy, Google)

We can also ask spaCy provide some explanation about the named entities.

doc[0], doc[0].ent_type_, spacy.explain(doc[0].ent_type_)

>>> (Rome, 'GPE', 'Countries, cities, states')

Again, we can rely on displacy to visualise the results of NER.

displacy.serve(doc, style="ent")
Image by Author

Final Thoughts

Understanding how language is structured and how it works is key to building better tools that can handle text in meaningful ways. Techniques like part-of-speech tagging, dependency parsing, and named entity recognition help break down sentences so we can see how words function, how they connect, and what real-world things they refer to.

These methods give us a practical way to pull useful information out of text, things like identifying who did what to whom, or spotting names, dates, and places. Libraries like spaCy make it easier to explore these ideas, offering clear ways to see how language fits together.

Source link

#Mastering #NLP #spaCy #Part

Tags: artificial intelligencedata sciencedeep learningmachine learningPythonStatisticstechnology
Previous Post

With Trump’s cutbacks, crew heads for ISS unsure of when they’ll come back

Next Post

The Download: How fertility tech is changing families, and Trump’s latest tariffs

AiNEWS2025

AiNEWS2025

Next Post
The Download: How fertility tech is changing families, and Trump’s latest tariffs

The Download: How fertility tech is changing families, and Trump's latest tariffs

Stay Connected test

  • 23.9k Followers
  • 99 Subscribers
  • Trending
  • Comments
  • Latest
A tiny new open source AI model performs as well as powerful big ones

A tiny new open source AI model performs as well as powerful big ones

0
Water Cooler Small Talk: The Birthday Paradox 🎂🎉 | by Maria Mouschoutzi, PhD | Sep, 2024

Water Cooler Small Talk: The Birthday Paradox 🎂🎉 | by Maria Mouschoutzi, PhD | Sep, 2024

0
Ghost of Yōtei: The acclaimed Ghost of Tsushima is getting a sequel

Ghost of Yōtei: The acclaimed Ghost of Tsushima is getting a sequel

0
Best Headphones for Working Out (2024): Bose, Shokz, JLab

Best Headphones for Working Out (2024): Bose, Shokz, JLab

0
Scaling Auditable Agentic Workflows in Financial Services – with Leaders from Moody’s and Prudential Insurance

Scaling Auditable Agentic Workflows in Financial Services – with Leaders from Moody’s and Prudential Insurance

2025-12-23
The Machine Learning “Advent Calendar” Day 22: Embeddings in Excel

The Machine Learning “Advent Calendar” Day 22: Embeddings in Excel

2025-12-23
In a surprise announcement, Tory Bruno is out as CEO of United Launch Alliance

In a surprise announcement, Tory Bruno is out as CEO of United Launch Alliance

2025-12-23
The FCC’s foreign drone ban is here

The FCC’s foreign drone ban is here

2025-12-23

Recent News

Scaling Auditable Agentic Workflows in Financial Services – with Leaders from Moody’s and Prudential Insurance

Scaling Auditable Agentic Workflows in Financial Services – with Leaders from Moody’s and Prudential Insurance

2025-12-23
The Machine Learning “Advent Calendar” Day 22: Embeddings in Excel

The Machine Learning “Advent Calendar” Day 22: Embeddings in Excel

2025-12-23
In a surprise announcement, Tory Bruno is out as CEO of United Launch Alliance

In a surprise announcement, Tory Bruno is out as CEO of United Launch Alliance

2025-12-23
The FCC’s foreign drone ban is here

The FCC’s foreign drone ban is here

2025-12-23
Footer logo

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Check our landing page for details.

Follow Us

Browse by Category

  • AI & Cloud Computing
  • AI & Cybersecurity
  • AI & Sentiment Analysis
  • AI Applications
  • AI Ethics
  • AI Future Predictions
  • AI in Education
  • AI in Fintech
  • AI in Gaming
  • AI in Healthcare
  • AI in Startups
  • AI Innovations
  • AI News
  • AI Research
  • AI Tools & Automation
  • Apps
  • AR/VR & AI
  • Business
  • Deep Learning
  • Emerging Technologies
  • Entertainment
  • Fashion
  • Food
  • Gadget
  • Gaming
  • Health
  • Lifestyle
  • Machine Learning
  • Mobile
  • Movie
  • Music
  • News
  • Politics
  • Review
  • Robotics & Smart Systems
  • Science
  • Sports
  • Startup
  • Tech
  • Travel
  • World

Recent News

Scaling Auditable Agentic Workflows in Financial Services – with Leaders from Moody’s and Prudential Insurance

Scaling Auditable Agentic Workflows in Financial Services – with Leaders from Moody’s and Prudential Insurance

2025-12-23
The Machine Learning “Advent Calendar” Day 22: Embeddings in Excel

The Machine Learning “Advent Calendar” Day 22: Embeddings in Excel

2025-12-23
  • About
  • Advertise
  • Privacy & Policy
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.