nlp_graph   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 12
dl 0
loc 15
rs 10
c 0
b 0
f 0
1
import spacy
2
3
nlp = spacy.load("en_core_web_sm")
4
doc = nlp("Apple is looking at buying U.K. startup for $1 billion")
5
for token in doc:
6
    print(token.text, token.pos_, token.dep_)
7
8
doc = nlp("Autonomous cars shift insurance liability toward manufacturers")
9
for chunk in doc.noun_chunks:
10
    print(chunk.text, chunk.root.text, chunk.root.dep_,
11
          chunk.root.head.text)
12
13
for token in doc:
14
    print(token.text, token.dep_, token.head.text, token.head.pos_, list(token.children))
15