python的自然语言生成库
nlglib的Python项目详细描述
安装
从存储库下载代码并运行python setup.py install或使用pip: pip安装nlglib。
简介
nlglib是一个用python编写的自然语言生成(nlg)库。 它试图填补NLG领域的空白。目前没有现成的 一个人可以接受并合并到其他项目中的库。 此库的目的是对希望 为它们的功能添加一些文本生成。
观众
没有语言知识的程序员应该可以使用这个库。 鉴于图书馆的目标是语言生成, 一些语言知识是必要的,但你应该能学会 从例子中。
历史记录
nlglib作为epsrc项目的一部分启动 scrutable自治系统(sassy):www.scrutable-systems.org 项目完成后,将代码移到此存储库中以创建 一个独立的可重用库。
示例
fromnlglib.realisation.simplenlg.realisationimportRealiserfromnlglib.microplanningimport*realise_en=Realiser(host='nlg.kutlak.info',port=40000)realise_es=Realiser(host='nlg.kutlak.info',port=40001)defmain():p=Clause("María","perseguir","un mono")p['TENSE']='PAST'# expected = 'María persigue un mono.'print(realise_es(p))p=Clause(NP("la","rápida","corredora"),VP("perseguir"),NP("un","mono"))subject=NP("la","corredora")objekt=NP("un","mono")verb=VP("perseguir")subject.premodifiers.append("rápida")p.subject=subjectp.predicate=verbp.object=objekt# expected = 'La rápida corredora persigue un mono.'print(realise_es(p))p=Clause(NP('this','example'),VP('show','how cool simplenlg is'))# expected = This example shows how cool simplenlg is.print(realise_en(p))if__name__=='__main__':main()