Download the PHP package sumpygump/rumble-text without Composer
On this page you can find all versions of the php package sumpygump/rumble-text. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sumpygump/rumble-text
More information about sumpygump/rumble-text
Files in sumpygump/rumble-text
Package rumble-text
Short Description Generate random text. Strings, digits, words, phrases, sentences, etc. To be used as placeholder text.
License MIT
Informations about the package rumble-text
Rumble Text
Rumbletext is a simple PHP library for generating random text.
My intent was to make a library suitable for generating placeholder (lorem ipsum) text. It uses a primitive algorithm for making pronouncable words. It comes with some various lettersets for use in probabilities of vowel and consonant distribution to assist in this.
Installation
To install, use composer with the following command:
Usage
As a library
The primary usage of this library is to use it as a service in a PHP project. Instantiate an instance of the class RumbleText and call the various functions like generateRandomWord(). This will return an random generated word.
Example:
List of available methods:
- generateRandomString($length, $chars)
- generateRandomPhrase($min = 1, $max = 5, $as_array = false)
- generateRandomSentence($min = 1, $max = 20, $as_array = false)
- generateRandomParagraph($min = 1, $max = 20, $exact_wordcount = null, $as_array = false)
- generateRandomArticle($min = 1, $max = 8, $exact_wordcount = null)
- generateRandomWord($length = 5, $lower_case = true, $ucfirst = false, $upper_case = false, $exactlength = false)
- generateRandomName($maxlength = 10)
- generateRandomCompany($maxwords = 2)
- generateRandomWebsite()
- generateRandomEmail()
- generateRandomDigits($minlength = 4, $maxlength = 16, $exactlength = 0)
- generateRandomPhone()
- generateRandomAddress()
As a CLI script
There is also a cli script that can be used to output various random strings from the command line.
Use rumble-text --help to get the following help message:
Lettersets
Below is a showcase of the lettersets available. Note: the lettersets are not used for the methods generateRandomString or generateRandomDigits
Original
The original letterset has a straightforward distribution of vowels and consonants. I fine-tuned it manually based on what I thought was aesthetically pleasing.
Caesar
The caesar letterset is based on the distribution of english word letters as described in the manpage of caesar:
The frequency (from most common to least) of English letters is as follows: ETAONRISHDLFCMUGPYWBVKXJQZ Their frequencies as a percentage are as follows: E(13), T(10.5), A(8.1), O(7.9), N(7.1), R(6.8), I(6.3), S(6.1), H(5.2), D(3.8), L(3.4), F(2.9), C(2.7), M(2.5), U(2.4), G(2), P(1.9), Y(1.9), W(1.5), B(1.4), V(.9), K(.4), X(.15), J(.13), Q(.11), Z(.07).
This letterset produces text like this:
Hayden
In my search for even better approximation of human words I found a paper by Rebecca Hayden where she described the various phonemes and their distribution in speech. I used the results of her paper to generate the hayden letterset.
Here is an example of hayden:
Equal
The equal letterset has a equal probability for selecting every letter in the alphabet. Unlike the previous examples, there is no weighting for certain letters, so you end up with more j, z, x, w and other rare letters.
Baba
The 'baba' letterset is just for fun. It will pick a random vowel and a random consonant and ONLY use those in generating words.
Example output. In this example, it picked 'x' and 'i':
Parseltongue
Parseltongue is another letterset just for fun. This one approximates the snake language from Harry Potter.