用于NLTK解析的英语语法 [英] English grammar for parsing in NLTK

查看:115
本文介绍了用于NLTK解析的英语语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在可以立即加载并在NLTK中使用的即用型英语语法?我搜索了使用NLTK进行解析的示例,但似乎我必须在解析句子之前手动指定语法.

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 manually specify grammar before parsing a sentence.

非常感谢!

推荐答案

您可以查看 pyStatParser ,这是一个简单的python返回NLTK解析树的统计解析器.它带有公共树库,并且仅在您首次实例化Parser对象时(大约8秒内)才生成语法模型.它使用CKY算法,并在一秒钟内解析平均长度的句子(如下面的句子).

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))))
  (. ?))

这篇关于用于NLTK解析的英语语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆