Spacy Python
Spacy Python:
import spacy
# Load the English language model
nlp = spacy.load(‘en_core_web_sm’)
# Process a text
doc = nlp(“Apple is looking at buying U.K. startup for $1 billion”)
# Iterate over the tokens in the document
for token in doc:
print(token.text, token.lemma_, token.pos_, token.dep_, token.is_stop)
# Iterate over the named entities in the document
for ent in doc.ents:
print(ent.text, ent.start_char, ent.end_char, ent.label_)
In the token loop, token.text
is the original word string, token.lemma_
is the base form of the word, token.pos_
is the simple part-of-speech tag, token.dep_
is the syntactic dependency relation, and token.is_stop
is a boolean indicating if the token is a stop word or not.
In the entity loop, ent.text
is the original entity string, ent.start_char
and ent.end_char
are the start and end indices of the entity in the original string, and ent.label_
is the type of the entity.
Please make sure to download the language models first, using python -m spacy download en_core_web_sm
, for example.
Note that Spacy’s capabilities go well beyond this, including text classification, similarity detection, rule-based matching, and integration with machine learning libraries like TensorFlow and PyTorch.
Python Training Demo Day 1
Conclusion:
Unogeeks is the No.1 IT Training Institute for Python Training. Anyone Disagree? Please drop in a comment
You can check out our other latest blogs on Python here – Python Blogs
You can check out our Best In Class Python Training Details here – Python Training
Follow & Connect with us:
———————————-
For Training inquiries:
Call/Whatsapp: +91 73960 33555
Mail us at: info@unogeeks.com
Our Website ➜ https://unogeeks.com
Follow us:
Instagram: https://www.instagram.com/unogeeks
Facebook: https://www.facebook.com/UnogeeksSoftwareTrainingInstitute
Twitter: https://twitter.com/unogeeks