是否有现成的英语语法可供我加载并在 NLTK 中使用?我搜索了使用 NLTK 进行解析的示例,但似乎我必须在解析句子之前手动指定语法。
多谢!
你可以看一下pyStat解析器 https://github.com/emilmont/pyStatParser,一个简单的 python 统计解析器,返回 NLTK 解析树。它带有公共树库,并且仅在您第一次实例化 Parser 对象时(大约 8 秒)才生成语法模型。它使用 CKY 算法,在一秒内解析平均长度的句子(如下所示)。
>>> 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))))
(. ?))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)