English grammar for parsing in NLTK

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

    You can take a look at pyStatParser, a simple python statistical parser that returns NLTK parse Trees. It comes with public treebanks and it generates the grammar model only the first time you instantiate a Parser object (in about 8 seconds). It uses a CKY algorithm and it parses average length sentences (like the one below) in under a second.

    >>> from stat_parser import Parser
    >>> parser = Parser()
    >>> print parser.parse("How can the net amount of entropy of the universe be massively decreased?")
    (SBARQ
      (WHADVP (WRB how))
      (SQ
        (MD can)
        (NP
          (NP (DT the) (JJ net) (NN amount))
          (PP
            (IN of)
            (NP
              (NP (NNS entropy))
              (PP (IN of) (NP (DT the) (NN universe))))))
        (VP (VB be) (ADJP (RB massively) (VBN decreased))))
      (. ?))
    

提交回复
热议问题