Crate lipsum

Source
Expand description

Lorem ipsum generator.

This crate contains functions for generating pseudo-Latin lorem ipsum placeholder text. The traditional lorem ipsum text start like this:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. […]

This text is in the LOREM_IPSUM constant. Random text looking like the above can be generated using the lipsum function. This function allows you to generate as much text as desired and each invocation will generate different text. This is done using a Markov chain based on both the LOREM_IPSUM and LIBER_PRIMUS texts. The latter constant holds the full text of the first book of a work by Cicero, of which the lorem ipsum text is a scrambled subset.

The random looking text is generatd using a Markov chain of order two, which simply means that the next word is based on the previous two words in the input texts. The Markov chain can be used with other input texts by creating an instance of MarkovChain and calling its learn method.

Structs§

  • Simple order two Markov chain implementation.
  • Never-ending iterator over words in the Markov chain.

Constants§

  • The first book in Cicero’s work De finibus bonorum et malorum (“On the ends of good and evil”). The lorem ipsum text in LOREM_IPSUM is derived from part of this text.
  • The traditional lorem ipsum text as given in Wikipedia. Using this text alone for a Markov chain of order two doesn’t work very well since each bigram (two consequtive words) is followed by just one other word. In other words, the Markov chain will always produce the same output and recreate the lorem ipsum text precisely. However, combining it with the full text in LIBER_PRIMUS works well.

Functions§

  • Generate n words of lorem ipsum text. The output will always start with “Lorem ipsum”.
  • Generate a short lorem ipsum text with words in title case.
  • Generate n words of random lorem ipsum text.

Type Aliases§

  • A bigram is simply two consecutive words.