pythonbeginner
spaCy Named Entity Recognition
Extract entities, dependencies, and noun phrases from text using spaCy's industrial-strength NLP pipeline.
pythonPress ⌘/Ctrl + Shift + C to copy
import spacy
nlp = spacy.load('en_core_web_sm')
texts = [
'Elon Musk founded SpaceX in Hawthorne, California in 2002.',
'OpenAI released GPT-4 in March 2023 and it was trained on a massive dataset.',
'The Python Software Foundation is based in Delaware, USA.',
]
for text in texts:
doc = nlp(text)
print(f'Text: {text}')
print(' Entities:')
for ent in doc.ents:
print(f' {ent.text!r:30} [{ent.label_}] - {spacy.explain(ent.label_)}')
noun_phrases = [chunk.text for chunk in doc.noun_chunks]
print(f' Noun phrases: {noun_phrases}\n')Use Cases
- entity extraction
- text mining
- information extraction
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
typescriptintermediate
AI Text Classification with Prompts
Classify text into categories using structured prompting with confidence scores and explanations.
Best for: Automated support ticket routing
#classification#prompt-engineering
pythonintermediate
Text Classification with Hugging Face
Fine-tune or use pre-trained Hugging Face models for text classification.
Best for: Sentiment analysis
#ai#huggingface
pythonbeginner
Sentence Transformers Local Embeddings
Generate high-quality text embeddings locally using Sentence Transformers without API calls.
Best for: semantic search
#sentence-transformers#embeddings
pythonbeginner
Hugging Face Transformers Pipeline
Run text classification, NER, summarisation, and translation tasks with the HF Pipelines API.
Best for: NLP tasks
#huggingface#transformers