lorem_ipsum module

  1. 2017 Martin Wendt; see https://github.com/mar10/fabulist

Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php

class LoremDialect(dialect: str, path: str)[source]

Bases: object

Generate lorem ipsum text.

Parameters:
  • dialect (str) – “lorem”, “pulp”, …

  • path (str)

Examples

$(TYPE:MODS:#foo|bar:=NUM)

load() None[source]
class LoremGenerator(data_folder: str)[source]

Bases: object

Generate lorem ipsum text in a given dialect.

dialect_map

Holds all available lorem-ipsum dialects

Type:

dict(dialect, LoremDialect)

generate_paragraphs(count: int | None = None, *, dialect: str | None = 'ipsum', entropy: int | None = 2, keep_first: bool | None = False, words_per_sentence: int | tuple[int, int] | None = (3, 15), sentences_per_para: int | tuple[int, int] | None = (2, 6)) Iterator[str][source]

Generate a number of paragraphs, made up from random sentences.

Parameters:
  • count (int, optional) – Number of paragraphs. Pass None for infinite. Default: None.

  • dialect (str, optional) – For example “ipsum”, “pulp”, “trappatoni”. Pass None to pick a random dialect. Default: “ipsum”.

  • keep_first (bool, optional) – Always return the first sentence as first result. Default: False.

  • entropy (int) – 0: iterate original text 1: pick a random paragraph, then use it literally 2: mix a random sentences 3: mix random words Default: 2.

  • words_per_sentence (int or tuple(min, max), optional) – Number of words per sentence. This argument is only used for entropy=3. Default: (3, 15).

  • sentences_per_para (int or tuple(min, max), optional) – Number of sentences per paragraph. Default: (2, 6).

Yields:

str – Random paragraph.

generate_sentences(count: int | None = None, *, dialect: str | None = 'ipsum', entropy: int | None = 2, keep_first: bool | None = False, words_per_sentence: int | tuple[int, int] | None = (3, 15)) Iterator[str][source]

Yield <count> random sentences.

Parameters:
  • count (int, optional) – Number of sentences. Pass None for infinite. Default: None.

  • dialect (str, optional) – For example “ipsum”, “pulp”, “trappatoni”. Pass None to pick a random dialect. Default: “ipsum” (i.e. lorem-ipsum).

  • entropy (int, optional) – 0: iterate sentences from original text 1: pick a random paragraph, then iterate sentences 2: pick a random sentence 3: mix random words Default: 2.

  • keep_first (bool, optional) – Always return the first sentence as first result. Default: False.

  • words_per_sentence (int or tuple(min, max), optional) – Number of words per sentence. This argument is only used for entropy=3. Default: (3, 15).

Yields:

str – Random sentence.

generate_words(count: int | None = None, *, dialect: str | None = 'ipsum', entropy: int | None = 3, keep_first: bool | None = False) Iterator[str][source]

Yield <count> random words.

Parameters:
  • count (int, optional) – Number of words. Pass None for infinite. Default: None.

  • dialect (str, optional) – For example “ipsum”, “pulp”, “trappatoni”. Pass None to pick a random dialect. Default: “ipsum” (i.e. lorem-ipsum).

  • entropy (int, optional) – 0: iterate words from original text 1: pick a random paragraph, then use it literally 2: pick a random sentence, then use it literally 3: pick random words Default: 3.

  • keep_first (bool, optional) – Always return the words of the first sentence as first result. Default: False.

Yields:

str – Random word.