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

Inheritance

Constructor

goog.text.LoremIpsum()

Instance Methods

Public Protected Private
chooseRandomStart_() Array.<string>
Picks a random starting chain.
Returns: Array.<string>  The starting key.
code »
generateChains_(sample)
Generates the chains and starts values required for sentence generation.
Arguments:
sample : string
The same text.
code »
generateParagraph(opt_startWithLorem) string
Generates a single lorem ipsum paragraph, of random length.
Arguments:
opt_startWithLorem : boolean
Whether to start the sentence with the standard "Lorem ipsum..." first sentence.
Returns: string  The generated sentence.
code »
generateParagraphStatistics_(sample)
Calculates the mean and standard deviation of the lengths of paragraphs (in sentences) in a sample text.
Arguments:
sample : string
The same text.
code »
generateSentence(opt_startWithLorem) string
Generates a single sentence, of random length.
Arguments:
opt_startWithLorem : boolean
Whether to start the setnence with the standard "Lorem ipsum..." first sentence.
Returns: string  The generated sentence.
code »
generateSentenceStatistics_(sample)
Calculates the mean and standard deviation of the lengths of sentences (in words) in a sample text.
Arguments:
sample : string
The same text.
code »
generateStatistics_(sample)
Calculates the mean and standard deviation of sentence and paragraph lengths.
Arguments:
sample : string
The same text.
code »
initializeDictionary_(dictionary)
Sets the generator to use a given selection of words for generating sentences with.
Arguments:
dictionary : string
The dictionary to use.
code »

Instance Properties

chains_ : goog.structs.Map
Chains of three words that appear in the sample text Maps a pair of word-lengths to a third word-length and an optional piece of trailing punctuation (for example, a period, comma, etc.).
Code »
dictionary_ :
Dictionary of words.
Code »
paragraphMean_ :
Averange paragraph length in sentences.
Code »
paragraphSigma_ :
Sigma (sqrt of variance) for the paragraph length in sentences.
Code »
sample_ :
Sample that the generated text is based on .
Code »
sentenceMean_ :
Averange sentence length in words.
Code »
sentenceSigma_ :
Sigma (sqrt of variance) for the sentence length in words.
Code »
starts_ :
Pairs of word-lengths that can appear at the beginning of sentences.
Code »
words_ : goog.structs.Map
Words that can be used in the generated output. Maps a word-length to a list of words of that length.
Code »

Static Methods

goog.text.LoremIpsum.arrayLength_(array) number
Returns the length of an array. Written as a function so it can be used as a function parameter.
Arguments:
array : Array
The array to check.
Returns: number  The length of the array.
code »
goog.text.LoremIpsum.chooseClosest(valuestarget) number
Find the number in the list of values that is closest to the target.
Arguments:
values : Array.<number>
The values.
target : number
The target value.
Returns: number  The closest value.
code »
goog.text.LoremIpsum.getWordInfo_(word) Array
Gets info about a word used as part of the lorem ipsum algorithm.
Arguments:
word : string
The word to check.
Returns: Array  A two element array. The first element is the size of the word. The second element is the delimter used in the word.
code »
goog.text.LoremIpsum.isNotEmptyOrWhitepace_(text) boolean
Returns the text is not empty or just whitespace.
Arguments:
text : string
The text to check.
Returns: boolean  Whether the text is nether empty nor whitespace.
code »
goog.text.LoremIpsum.randomChoice_(array) *
Picks a random element of the array.
Arguments:
array : Array
The array to pick from.
Returns: *  An element from the array.
code »
goog.text.LoremIpsum.randomNormal_(musigma)
Generates a random number for a normal distribution with the specified mean and sigma.
Arguments:
mu : number
The mean of the distribution.
sigma : number
The sigma of the distribution.
code »
goog.text.LoremIpsum.splitParagraphs_(text) Array.<string>
Splits a piece of text into paragraphs.
Arguments:
text : string
The text to split.
Returns: Array.<string>  An array of paragraphs.
code »
goog.text.LoremIpsum.splitSentences_(text) Array.<string>
Splits a piece of text into sentences.
Arguments:
text : string
The text to split.
Returns: Array.<string>  An array of sentences.
code »
goog.text.LoremIpsum.splitWords_(text) Array.<string>
Splits a piece of text into words..
Arguments:
text : string
The text to split.
Returns: Array.<string>  An array of words.
code »

Static Properties

goog.text.LoremIpsum.DELIMITERS_SENTENCES_ :
Delimiters that end sentences.
Code »
goog.text.LoremIpsum.DELIMITERS_WORDS_ :
Delimiters that end words.
Code »
goog.text.LoremIpsum.DICT_ :
Dictionary of words for lorem ipsum.
Code »
goog.text.LoremIpsum.NV_MAGICCONST_ :
Constant used for #randomNormal_.
Code »
goog.text.LoremIpsum.SAMPLE_ :
A sample to use for generating the distribution of word and sentence lengths in lorem ipsum.
Code »
goog.text.LoremIpsum.SENTENCE_SPLIT_REGEX_ :
Regular expression for spliting a text into sentences.
Code »
goog.text.LoremIpsum.WORD_SPLIT_REGEX_ :
Regular expression for spliting text into words.
Code »

Package text

Package Reference