I have a table called posts
in my database and each record represents a post with title
, url
and body
.
Is it possible to use Faker to generate titles and bodies in English? The body should be actual English text.
I went through the docs and didn't find what I'm looking for.
For English texts, why can't you do this?
Faker::Quote.matz
=> "I believe that the purpose of life is, at least in part, to be happy. Based on this belief, Ruby is designed to make programming not only easy but also fun. It allows you to concentrate on the creative side of programming, with less stress."
Or try:
Faker::Hipster.sentences.sample
=> "Cornhole drinking actually pop-up brooklyn williamsburg wayfarers."
For Titles, just do
[Faker::Company.name, Faker::Company.industry].join(' - ')
=> "Schmitt-Kohler - E-Learning"
But if you really need some random actual sentences you can pull them from random book texts and use this gem to easily grab sentences.
require "tactful_tokenizer"
t = TactfulTokenizer::Model.new
string = `curl http://www.textfiles.com/etext/FICTION/alger-cast-544.txt`;
sentences = t.tokenize_text(string);
sentences.count
=> 6322
sentences.sample
"I'm just staying at a place on Fourteenth Street, but I can't
afford to stay there long, for they charge a dollar a day."