Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not random #59

Open
stuartcrobinson opened this issue Feb 7, 2020 · 2 comments
Open

not random #59

stuartcrobinson opened this issue Feb 7, 2020 · 2 comments
Assignees

Comments

@stuartcrobinson
Copy link

i thought it was going to be random text, but it generates the same thing every time per length.

println!("{}", lipsum(5));
println!("{}", lipsum(5));
println!("{}", lipsum(5));
println!("{}", lipsum(5));

Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.

@mgeisler mgeisler self-assigned this Feb 23, 2020
@mgeisler
Copy link
Owner

Hi @stuartcrobinson ! Thanks for the question, you raise a good point.

The lipsum function always starts with the words "Lorem ipsum" since I figured people liked the traditional look of the text. After that it continues in a random fashion based on the text in

Because it includes punctionation such as , and ! when picking the next word, you actually have to waid a long time until you see any randomness. In fact, the first 18 words are fixed! That feels like a very long time indeed and I will see if I make this shorter while preserving the "look and feel".

In the meantime, I suggest using lipsum_words instead: https://docs.rs/lipsum/0.6.0/lipsum/fn.lipsum_words.html. That generates random words from the get go.

@A6GibKm
Copy link

A6GibKm commented May 11, 2024

I am currently using the library at https://flathub.org/apps/org.gnome.design.Lorem, I encountered the problem that when calling lipsum_words they start all with

Ullus investigandi veri, nisi inveneris, et quaerendi defatigatio turpis est, cum esset accusata et vituperata ab Hortensio

the usecase is to create multiple paragraphs with lengths (in number of words) given from a Vec<usize>. Unfortunately if all paragraphs start the same it does not look very natural.

For reference the code looks like

                let mut rng = rand::thread_rng();

                let texts: Vec<String> = (0..n)
                    .map(|i| {
                        let m = rng.gen_range(30..70);
                        match i {
                            0 => lipsum::lipsum(m),
                            _ => lipsum::lipsum_words(m),
                        }
                    })
                    .collect();

                texts.join("\n\n")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants