Skip to content
NLP with Spacy
# Imports the English language class
# from spacy.lang.en import English
# Creates the NLP object
# nlp = English()
# The Doc Object/ Created by processing this string with the nlp object
# doc = nlp("Hello World!")
# for token in doc:
# print(token.text) #Output will be Hello, World, and ! on seperate lines
# To get a span from the doc, use the slicing method
#span = doc[1:]
#print(span) # Output will be World! on the same lineimport spacy
# Load the small English model of spacy
nlp = spacy.load('en_core_web_sm')
text = "Apple is now worth $5 Billion."
doc = nlp(text)
for token in doc:
print(token.text, token.pos_)