...

/

Solution: Linguistic Features

Solution: Linguistic Features

Let's look at the solution to the previous exercise.

We'll cover the following...

Solution

In the code snippet below, we have given the solution to the previous problem.

Press + to interact
import spacy
nlp = spacy.load("en_core_web_md")
text = "Apple is looking at buying U.K. startup for $1 billion"
doc = nlp(text)
for token in doc:
print(f"{token.text} {token.pos_} {token.dep_}")
for ent in doc.ents:
print("{ent.text} {ent.label_}")

Solution explanation

  • Lines 1 and 2: We import the spacy library and load an English model using spacy.load. ...