English grammar for parsing in NLTK

后端 未结 8 868
没有蜡笔的小新
没有蜡笔的小新 2020-11-29 20:02

Is there a ready-to-use English grammar that I can just load it and use in NLTK? I\'ve searched around examples of parsing with NLTK, but it seems like that I have to manual

8条回答
  •  鱼传尺愫
    2020-11-29 21:03

    My library, spaCy, provides a high performance dependency parser.

    Installation:

    pip install spacy
    python -m spacy.en.download all
    

    Usage:

    from spacy.en import English
    nlp = English()
    doc = nlp(u'A whole document.\nNo preprocessing require.   Robust to arbitrary formating.')
    for sent in doc:
        for token in sent:
            if token.is_alpha:
                print token.orth_, token.tag_, token.head.lemma_
    

    Choi et al. (2015) found spaCy to be the fastest dependency parser available. It processes over 13,000 sentences a second, on a single thread. On the standard WSJ evaluation it scores 92.7%, over 1% more accurate than any of CoreNLP's models.

提交回复
热议问题