The goog.text.LoremIpsum Class

goog.text.LoremIpsum()

Generates random strings of "lorem ipsum" text, based on the word distribution of a sample text, using the words in a dictionary.

.arrayLength_(array)

Returns the length of an array. Written as a function so it can be used as a function parameter.

array {Array}
The array to check.
returns {number}
The length of the array.

.chooseClosest(values, target)

Find the number in the list of values that is closest to the target.

values {Array.<number>}
The values.
target {number}
The target value.
returns {number}
The closest value.

.dictionary_ {string}

Dictionary of words.

.generateParagraph(opt_startWithLorem)

Generates a single lorem ipsum paragraph, of random length.

opt_startWithLorem {boolean}
Whether to start the sentence with the standard "Lorem ipsum..." first sentence.
returns {string}
The generated sentence.

.generateSentence(opt_startWithLorem)

Generates a single sentence, of random length.

opt_startWithLorem {boolean}
Whether to start the setnence with the standard "Lorem ipsum..." first sentence.
returns {string}
The generated sentence.

.initializeDictionary_(dictionary)

Sets the generator to use a given selection of words for generating sentences with.

dictionary {string}
The dictionary to use.

.randomChoice_(array)

Picks a random element of the array.

array {Array}
The array to pick from.
returns {*}
An element from the array.

.sample_ {string}

Sample that the generated text is based on .

.starts_ {Array}

Pairs of word-lengths that can appear at the beginning of sentences.