Skip to main content

Generates books based on other books using nltk

Project description

bookgen

A python library using nltk to analyse two books and generate a new one.

Installation

pip install bookgen

Usage

from bookgen import BookGen

book = BookGen("word_base_book.txt", "sentence_base_book.txt")
# book.download() will download the nltk extras required, only needed once

print(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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bookgen-1.0.0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

bookgen-1.0.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file bookgen-1.0.0.tar.gz.

File metadata

  • Download URL: bookgen-1.0.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.6.6

File hashes

Hashes for bookgen-1.0.0.tar.gz
Algorithm Hash digest
SHA256 326b5ec5b16c8e7884a98ef324fee3c8a3721164867a9baaf0fdcd1d7a524a48
MD5 4b8365f1f36f618bb38c0bbe400b3a27
BLAKE2b-256 373e54cf3dfe2241bb65137b72bb280bbb33799daa20652362ea2fe05b3e7223

See more details on using hashes here.

File details

Details for the file bookgen-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: bookgen-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.6.6

File hashes

Hashes for bookgen-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a031905b168bc6050bc7f3f10e43940b537b8c1f0c53a8605ccb22e62226805
MD5 6e5bb26c7f55f729f4a2b846c1de7467
BLAKE2b-256 9be2da6c8dbbc666724e6d523f2dabf9546ae3ccc409ee4ab5b682173a3b1b62

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page