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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file momblish-0.2.1.tar.gz.
File metadata
- Download URL: momblish-0.2.1.tar.gz
- Upload date:
- Size: 54.8 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
902338bbe82710f363b2c42395de07be65cc23efa10706c1f93ee64ea5c80048
|
|
| MD5 |
22a268b120de10691613da02a36dbf36
|
|
| BLAKE2b-256 |
69bf48565a3fb95404862d0d17c97b218dc52802b6ef7b0741cd1ce5f6b1e0bc
|
File details
Details for the file momblish-0.2.1-py3-none-any.whl.
File metadata
- Download URL: momblish-0.2.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d66a3c0a573e61c77b2eb8503d521173ed56aece12abffcca4fa2ab57186305c
|
|
| MD5 |
67ce70c2f249f65adc2637ad5b78ff5a
|
|
| BLAKE2b-256 |
340d23afe83d6d391dfb1394ffd02dfa2a88f8e5247e2af537b0b5b67f871470
|