Skip to main content

nabg (New-Age Bullshit Generator)

PyPI version License: MIT Code style: black

What is it?

nabg lets you generate randomized sentences using pre-defined sentence patterns and a vocabulary. The default vocabulary and sentences are based on Seb Pearce's "New Age Bullshit Generator". You can also provide your own sentence patterns and word lists to generate customized bullshit.

Installing nabg

nabg is available on PyPI:

pip install nabg

Usage

Generating New-Age Bullshit

nabg comes with Seb Pearce's "New-Age Bullshit Generator". To generate new-age bullshit, in python you can do:

import nabg

# Generate new-age bullshit
nabg.ionize()

# List the available topics
nabg.list_topics()

# Generate 5 bullshit sentences with topic history
nabg.ionize(5, "history")

Or, you can use the CLI:

# Generate new-age bullshit
$ nabg

# List the available topics
$ nabg --list-topics

# Generate 5 bullshit sentences with topic history
$ nabg -n 5 -t history

Generating Custom Bullshit

nabg also lets you use your own sentence patterns and vocabulary to generate sentences.

from nabg import BullshitGenerator

# ---------------------------------------------------------------------------- #
# Custom sentence patterns. A dictionary with a list of patterns for each      #
# topic. All instances of ${vocabType} will be replaced with a randomly picked #
# word of type "vocabType" from the vocabulary.                                #
# ---------------------------------------------------------------------------- #

patterns = {
    "topic1": [
        "This is a ${adj} sentence.",
        "This is a ${adjPrefix}${adj} sentence."
    ],
    "topic2": [
        "We can no longer afford to live with ${nMassBad}.",
        "Without ${nMass}, one cannot ${viPerson}.",
    ],
}


# ---------------------------------------------------------------------------- #
# Custom vocabulary. A dictionary with a list of buzzwords for each type.      #
# Each type used in a sentence pattern must have at least one word in the      #
# vocabulary.                                                                  #
# ---------------------------------------------------------------------------- #

vocabulary = {
    "adj": [
        "fantastic",
        "stupid",
        "amazing",
    ],
    "adjPrefix": [
        "ultra-",
        "semi-",
    ],
    "nMass": [
        "knowledge",
        "truth",
    ],
    "nMassBad": [
        "pain",
        "suffering",
    ],
    "viPerson": [
        "exist",
        "believe",
    ],
}

# Create a bullshit generator object
bullshit_generator = BullshitGenerator(patterns, vocabulary)

# Generate custom bullshit
bullshit_generator.ionize(5, "topic1")

BullshitGenerator ensures that sentence patterns aren't repeated on multiple calls to BullshitGenerator.ionize(). If there are no unused sentence patterns remaining in the pool for the requested topic, another topic is chosen at random. This behavior can be customised by calling any of the three methods below:

# The three methods below can be used to set BullshitGenerator's behavior
# when no more unused patterns are available for the requested topic.

# Pick a different topic at random. This is the default behavior.
bullshit_generator.use_random_topic_when_out_of_patterns()

# Reset the pool. This would cause previously used patterns to repeat.
bullshit_generator.reset_pool_when_out_of_patterns()

# Raise a NoPatternsAvailableError.
bullshit_generator.raise_error_when_out_of_patterns()

When all sentence patterns across all topics have been used up, the pool is reset. This behavior can be customised by calling any of the two methods below:

# The two methods below can be used to set BullshitGenerator's behavior
# when all patterns across topics have been used up.

# Automatically reset the pool. This is the default behavior.
bullshit_generator.enable_auto_reset()

# Raise a NoPatternsAvailableError.
bullshit_generator.disable_auto_reset()

You can reset the pool manually at any time by calling:

bullshit_generator.reset_sentence_patterns()

Note: Successive calls to nabg.ionize() are not guaranteed to have distinct sentence patterns across calls (or in other words, the pool is reset after each call to nabg.ionize()). However, the sentence patterns and vocabulary for the default new-age bullshit generator can be used to create your own instance of BullshitGenerator to customize this behaviour:

from nabg import BullshitGenerator, patterns, vocabulary

# Create a BullshitGenerator object using Seb Pearce's pattern and vocabulary set
bullshit_generator = BullshitGenerator(patterns, vocabulary)

# The calls below are guaranteed to use different sentence patterns
print(bullshit_generator.ionize(3))
print(bullshit_generator.ionize(5))
print(bullshit_generator.ionize(2))

# Reset the pool
bullshit_generator.reset_sentence_patterns()

# The below call might use the same sentence pattern as one of the above calls as the pool has been reset
print(bullshit_generator.ionize())

Developing nabg

git clone https://github.com/naveen-u/nabg.git
  • Create and activate a virtual environment:
virtualenv venv
source venv/bin/activate
  • To install nabg, along with along with the tools you need to develop and run tests, run the following in your virtualenv: :
pip3 install -e .[dev]

References

  • The original New-Age Bullshit Generator by Seb Pearce - sebpearce.
  • The Python2 CLI - mcquiggi.

Authors

  • Naveen Unnikrishnan - Initial work - naveen-u

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Metadata

Release files for nabg 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nabg 1.0.2
File Size Uploaded
nabg-1.0.2.tar.gz 15.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nabg 1.0.2
File Interpreter ABI Platform
nabg-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 28.6 kB

Release files / nabg-1.0.2.tar.gz

Download URL nabg-1.0.2.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
42665a57d4a2f051208a3296d80a16542438c8a8e2325c7a20d31bdc4aa32cc5
BLAKE2b-256 checksum
How to use checksums
aa1640386aa77b150bce6e7706cdf9dc431bf8a4addec20766a58e9931c8df90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / nabg-1.0.2-py3-none-any.whl

Download URL nabg-1.0.2-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90c0b249d4f179f12cf2681dcf45596f7a02d46ca39c5699c93bc124eec83acd
BLAKE2b-256 checksum
How to use checksums
0bed24ef088dc8c9b631f3f6a79cffd660eac0978e6bd998dbd4b85fa7d1e4a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page