Skip to main content

Generate nonsense words from a corpus using trigram analysis

Project description

momblish

Momblish is a small library and CLI for generating fake-but-pronounceable words from a source corpus.

http://mentalfloss.com/article/69880/7-fake-words-ended-dictionary

It is named after a "fake" word put into the OED on accident.

Momblish uses trigram analysis to generate mostly pronounceable gibberish, so it can be used for any language that can be n-gram analyzed.

Description

To use momblish, import it.

from momblish import Momblish

m = Momblish.english()

The built-in English loader analyzes the system dictionary once and caches the result in the XDG cache directory.

from momblish import Momblish
from momblish.corpus import Corpus

m = Momblish.english()
m.corpus.save("/tmp/corpus.json")

c = Corpus.load("/tmp/corpus.json")
n = Momblish(c)

To generate words directly, call word() on a Momblish instance. sentence() returns a generator of words of varying length.

m.word()                     # => "PONESSAL"
m.word(10)                   # => "MIDONIHYLA"
m.word(6, prefix="d")        # => "D..."
m.word(7, prefix="dabc")     # => "DABCADC"
w = m.sentence()
next(w)                      # => "TICK"
next(w)                      # => "DRIXY"
next(w)                      # => "UNREA"
m.sentence(3, word_length=5) # => ["LEDGE", "DEAKA", "HONGI"]

You can also analyze your own corpus file.

custom = Momblish.from_file("/tmp/words.txt")
custom.word(8, prefix="tr")

There is also a command-line interface for quick generation without writing code.

$ momble 6
$ momble 7 dabc
$ momble --rebuild-cache 7 dabc
$ momble --corpus /tmp/words.txt 7 dabc

The CLI uses the cached analyzed corpus when available. Pass --rebuild-cache to force re-analysis of either the default English corpus or the file supplied with --corpus.

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

momblish-0.2.0.tar.gz (41.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

momblish-0.2.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file momblish-0.2.0.tar.gz.

File metadata

  • Download URL: momblish-0.2.0.tar.gz
  • Upload date:
  • Size: 41.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for momblish-0.2.0.tar.gz
Algorithm Hash digest
SHA256 768e064dd580e51b0133212c8c27cfcd2ebd4b16fca982d6619af08cfd204bf8
MD5 d2ce218d5b183f3368a87893729fac8c
BLAKE2b-256 0c5c1fe79554af116794b6e6d3bef81ac658522507a4bc939c867d40ea916684

See more details on using hashes here.

File details

Details for the file momblish-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: momblish-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for momblish-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 45f708fdd3e1d646b4de119dcf4f4fdde6c00cb517b709dc2ea91918daeb5314
MD5 ba9905f18f434af226e0b8757f2b6090
BLAKE2b-256 15f82ee75308811c76ff48ee0ac97293bc8dfa5cdfbc45ea220af634bb61dc0e

See more details on using hashes here.

Supported by

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