| Total Complexity | 0 |
| Total Lines | 15 |
| Duplicated Lines | 0 % |
| Changes | 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 |