Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: nlp_named_entity_spacy.py
- # Author: Jeoi Reqi
- """
- This script performs Named Entity Recognition (NER) using SpaCy.
- Requirements:
- - Python 3
- - SpaCy library
- - 'en_core_web_md' SpaCy model
- Usage:
- - Run the script, and it will identify named entities in the provided text.
- Example:
- python named_entity_spacy.py
- Output: Named Entities: [('Natural Language Processing', 'ORG')]
- """
- import spacy
- # Load the 'en_core_web_md' SpaCy model
- nlp = spacy.load("en_core_web_md")
- # Sample text
- text = "Natural Language Processing is a fascinating field. It involves the use of computers to understand and process human language."
- # Process the text using SpaCy
- doc = nlp(text)
- # Named Entity Recognition using SpaCy
- entities = [(ent.text, ent.label_) for ent in doc.ents]
- print("Named Entities:", entities)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement