Generate random strings that make sense.
|Version:||1.2, Jun 02, 2021|
This is a hobby project in its early phase. I am not planning to invest vast efforts here, but I am curious to get your feedback.
- Create random words, terms, or sentences based on templates.
- Pick words by word type (noun, adj, …), word form (‘ing’-form, comparative, plural, …), or tag (#animal, #positive, …).
- Generate random names.
- Generate blind text (lorem-ipsum et al).
Unlike other libraries, Fabulist focuses on generating strings with a pseudo-semantic, by supporting a simple grammar. This allows to display text that is more apposite (and fun) in a given context.
Install using pip:
$ pip install fabulist
fabulist package can be used in Python code:
$ python >>> from fabulist import Fabulist >>> fab = Fabulist() >>> fab.get_word("Noun") 'Equipment' >>> fab.get_word("adj", "#positive") 'kind' >>> fab.get_name("mr:middle") 'Mrs. Julia P. Hughes' >>> fab.get_quote("Look, some $(noun:#animal:plural)!") 'Look, some manatees!'
Running out of fortune cookies?
from fabulist import Fabulist fab = Fabulist() templates = [ "$(Verb:ing) is better than $(verb:ing).", "$(Noun:an) a day keeps the $(noun:plural) away.", "If you want to $(verb) $(adv), $(verb) $(adv)!", 'Confucius says: "The one who wants to $(verb) must $(verb) $(adv) the $(noun)!"', ] for q in fab.generate_quotes(templates, count=10): print("- ", q)
will produce something like:
- A statement a day keeps the airports away. - Savoring is better than magnifying. - If you want to sate divisively, disuse calmly! - Praying is better than inspecting. - Confucius says: "The one who wants to sterilize must inform miserably the possibility!" - If you want to blur orderly, stride poorly! - A cost a day keeps the gears away. - Subtracting is better than worshipping. - If you want to damage solely, discuss jealously! - Confucius says: "The one who wants to vanish must swear terribly the punch!"
Need some blind text?
fab.get_lorem_paragraph(3, dialect="pulp", entropy=1)
returns a paragraph with 3 sentences:
Do you see any Teletubbies in here? Do you see a slender plastic tag clipped to my shirt with my name printed on it? Do you see a little Asian child with a blank expression on his face sitting outside on a mechanical helicopter that shakes when you put quarters in it?