How do I do dependency parsing in NLTK?

前端 未结 7 958
醉梦人生
醉梦人生 2020-11-29 20:53

Going through the NLTK book, it\'s not clear how to generate a dependency tree from a given sentence.

The relevant section of the book: sub-chapter on dependency gra

7条回答
  •  醉梦人生
    2020-11-29 21:13

    If you need better performance, then spacy (https://spacy.io/) is the best choice. Usage is very simple:

    import spacy
    
    nlp = spacy.load('en')
    sents = nlp(u'A woman is walking through the door.')
    

    You'll get a dependency tree as output, and you can dig out very easily every information you need. You can also define your own custom pipelines. See more on their website.

    https://spacy.io/docs/usage/

提交回复
热议问题