0
0
NLPml~5 mins

spaCy installation and models in NLP

Choose your learning style9 modes available
Introduction

spaCy helps computers understand human language. Installing it and its models lets you use ready tools to work with text easily.

You want to find names or places in a text automatically.
You need to split sentences or words for analysis.
You want to tag parts of speech like nouns and verbs.
You want to build a chatbot that understands user messages.
You want to quickly test language processing without building from scratch.
Syntax
NLP
pip install spacy
python -m spacy download en_core_web_sm

Use pip install spacy to install the main spaCy library.

Use python -m spacy download <model_name> to get language models needed for processing.

Examples
Installs the spaCy library so you can use it in Python.
NLP
pip install spacy
Downloads a small English language model for spaCy to understand English text.
NLP
python -m spacy download en_core_web_sm
Downloads a small German language model for spaCy.
NLP
python -m spacy download de_core_news_sm
Sample Model

This program loads the English model, processes a sentence, and prints the named entities like companies and money amounts it finds.

NLP
import spacy

# Load the small English model
nlp = spacy.load('en_core_web_sm')

# Process a text
text = "Apple is looking at buying U.K. startup for $1 billion"
doc = nlp(text)

# Print named entities found in the text
for ent in doc.ents:
    print(ent.text, ent.label_)
OutputSuccess
Important Notes

Make sure to install the model that matches your language needs.

Models can be large; small models are faster but less detailed.

Run installation commands in your command line or terminal, not inside Python code.

Summary

Install spaCy with pip install spacy.

Download language models using python -m spacy download <model_name>.

Load models in Python with spacy.load() to process text.