Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gelbpunkt/bookgen
Generates books based on other books using nltk
https://github.com/gelbpunkt/bookgen
Last synced: 5 days ago
JSON representation
Generates books based on other books using nltk
- Host: GitHub
- URL: https://github.com/gelbpunkt/bookgen
- Owner: Gelbpunkt
- License: mit
- Created: 2019-01-10T18:07:37.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-10T18:25:51.000Z (about 6 years ago)
- Last Synced: 2024-08-09T23:48:46.262Z (5 months ago)
- Language: Python
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bookgen
A python library using nltk to analyse two books and generate a new one.
## Installation
`pip install bookgen`
## Usage
```py
from bookgen import BookGenbook = BookGen("word_base_book.txt", "sentence_base_book.txt")
# book.download() will download the nltk extras required, only needed onceprint(book.run())
```## Explanation
BookGen will parse word classes from the first specified book, looking like this:
`{"NOUN": ["Mountain", "Valley"], "VERB": ["take", "went"]}`
These are sorted by the nltk universal tagset.
The second book serves as sentence base. It will be parsed into a list of word types that represent the whole book.
`["NOUN", "VERB", "PREP", "NOUN", "CONJ", "VERB", "."]`
Then, it generates a list of words from the words of the first book based on the second book.
`["Nathan", "went", "to", "Valley", "and", "peed", "."]`
This is joined with some capitalization fixes and returned.