Open stephbuon opened 1 year ago
Instead of just extracting the subject or just the object, extract the whole noun chunk. See under "Noun chunks": https://spacy.io/usage/linguistic-features#dependency-parse
import spacy nlp = spacy.load("en_core_web_sm") doc = nlp("Autonomous cars shift insurance liability toward manufacturers") for chunk in doc.noun_chunks: print(chunk.text, chunk.root.text, chunk.root.dep_, chunk.root.head.text)
@steph to validate
Instead of just extracting the subject or just the object, extract the whole noun chunk. See under "Noun chunks": https://spacy.io/usage/linguistic-features#dependency-parse