使用nltk基于其他图书生成图书
bookgen的Python项目详细描述
BookGen
使用nltk分析两本书并生成一本新书的python库。
安装
pip install bookgen
用法
frombookgenimportBookGenbook=BookGen("word_base_book.txt","sentence_base_book.txt")# book.download() will download the nltk extras required, only needed onceprint(book.run())
说明
bookgen将解析第一本指定书籍中的单词类,如下所示:
{"NOUN": ["Mountain", "Valley"], "VERB": ["take", "went"]}
这些是由nltk通用标记集排序的。
第二本书是句子的基础。它将被解析成代表整本书的单词类型列表。
["NOUN", "VERB", "PREP", "NOUN", "CONJ", "VERB", "."]
然后,它基于第二本书从第一本书的单词中生成一个单词列表。
["Nathan", "went", "to", "Valley", "and", "peed", "."]
这与一些大写修复程序合并并返回。