How to get a 'dobj' in spacy -
in following tweet spacy dependency tagger states disrupt (vb) dobj of healthcare market (nn). these 2 terms connected extract them 1 phrase. there way navigate parse tree can extract dobj of word? if folllowing market not 'heathcare market'
from spacy.en import english spacy.symbols import nsubj, verb,dobj nlp = english() doc = nlp('juniper research: ai start-ups set disrupt healthcare market, $800 million spent on cad systems 2022') possible_subject in doc: if possible_subject.dep == dobj: print(possible_subject.text)
you can below using noun chunks
for np in doc.noun_chunks: if np.root.dep == dobj: print(np.root.text) print(np.text)
Comments
Post a Comment