Dependency Parsing in Spacy

101 views Asked by At

I want to extract the pair verb-noun of my text using dependency parsing. I did this:

document = nlp('appoint department heads or managers and assign or delegate responsibilities to them    ')
print ("{:<15} | {:<8} | {:<15} | {:<20}".format('Token','Relation','Head', 'Children'))
print ("-" * 70)

for token in document:
  print ("{:<15} | {:<8} | {:<15} | {:<20}"
         .format(str(token.text), str(token.dep_), str(token.head.text), str([child for child in token.children])))
  
  
from spacy import displacy
displacy.render(document, style = 'dep', jupyter=True )

Can you guys help me do a cleaner one?

0

There are 0 answers