English grammar for parsing in NLTK

后端 未结 8 835
没有蜡笔的小新
没有蜡笔的小新 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.

    0 讨论(0)
  • 2020-11-29 21:03

    Use the MaltParser, there you have a pretrained english-grammar, and also some other pretrained languages. And the Maltparser is a dependency parser and not some simple bottom-up, or top-down Parser.

    Just download the MaltParser from http://www.maltparser.org/index.html and use the NLTK like this:

    import nltk
    parser = nltk.parse.malt.MaltParser()
    
    0 讨论(0)
提交回复
热议问题