paukparl-book

Generated Self-Help Books

These are generated book covers (front and back) of self-help books, each with a different instruction on how to live your life.

 

Process

Lately I've been consumed by an unhealthy obsession with how to lead my life and how to start my career. Since we were making a book, I wanted it to make be about me. I hoped to resolve some of my issues through introspection.

During the process, I was somehow reminded of the sheer number of self-help books out there that instruct you on how to live your life. When you see too  many of them sometimes, you are made to think that it is that important to live your life to your fullest, when it just as well might not be that important. My book was an attempt to emulate, and thereby mock, these self-help books

I based most of my word selections on Text Corpora and used minimal code from RiTa.js library. For example, the title was drawn from corpora/data/words/common.json directory with a few filters such as (!RiTa.isNoun()). I also made a few template strings for subtitles, and a few arrays of words related to success. I think I could have hidden the repeating pattern and made more clever and controlled title-subtitle matches by using the Wordnik API. But there are still some examples that show the script is doing its job.

google drive link to 25 instances

 

Code

Some snippets of code showing functions for title and subtitle generation, and where I got the data.

adv = ['conveniently', 'quickly', 'certainly', 'effortlessly', 'immediately', 'completely']
adj = ['convenient', 'undisputed', 'quick', 'secret', 'true', 'groundbreaking', 'revolutionary']
obj = ['success', 'a successful career', 'true happiness', 'a new life', 'a healthier lifestyle']
v = ['succeed', 'win', 'challenge yourself', 'be successful', 'achieve success', 'get ahead in life', 'be famous', 'be happy', 'lose weight', 'make your dreams come true', 'plan ahead', 'make more friends']
 
function preload() {
    firstNames = loadJSON('/corpora-master/data/humans/firstNames.json');
    lastNames = loadJSON('/corpora-master/data/humans/authors.json');
    common = loadJSON('/corpora-master/data/words/common.json');
    adverbs = loadJSON('/corpora-master/data/words/adverbs.json');
    adjectives = loadJSON('/corpora-master/data/words/encouraging_words.json');
    newspapers = loadJSON('/corpora-master/data/corporations/newspapers.json');
}
 
...
...
...
 
function genTitle() {
    var temp = common[floor(random(common.length))];
    if (RiTa.isNoun(temp) || RiTa.isAdjective(temp) || RiTa.isAdverb(temp)
        || !RiTa.isVerb(temp) || temp.length >7) return genTitle();
    else return temp;
}
 
function randomDraw(array) {
    return array[floor(random(array.length))];
}
 
function genSubtitle() {
    temp = random(10);
    str;
    if (temp<2.3) str = 'How to ' + randomDraw(adv) + ' ' + randomDraw(v) + ' and ' + randomDraw(v);
    else if (temp<4.6) str = 'A ' + floor(random(12)+3) + '-step guide to ' + randomDraw(obj);
    else if (temp<6.6) str = floor(random(9)+3) + ' ways to ' + randomDraw(adv) + ' ' + randomDraw(v);
    else if (temp<8.6) str = 'A ' + randomDraw(adj) + ' guide on how to ' + randomDraw(v);
    else str = 'If only I had known then these ' + floor(random(12)+3) + ' facts of life';
 
    return str;
}
 
function genAuthor() {
        gen = {};
        gen['books'] = [];
        gen['author'] = firstNames[floor(random(firstNames.length))] 
                + ' ' + lastNames[floor(random(lastNames.length))];
 
        for (let i=0; i<8; i++) {
            book = {};
            book['title'] = genTitle();
            book['subtitle'] = genSubtitle();
 
            book['quotes'] = [];
            book['reviews'] = [];
            for (let j=0; j<5; j++) {
            review = {}
            temp = random(4);
            var reviewString;
            if (temp<1.2) reviewString = adverbs[floor(random(adjectives.length))] + ' ' + adjectives[floor(random(adjectives.length))] + ' and ' + adjectives[floor(random(adjectives.length))] +'.';
            else if (temp<2.0) reviewString = adverbs[floor(random(adjectives.length))] + ' ' + adjectives[floor(random(adjectives.length))] + ' but ' + adjectives[floor(random(adjectives.length))] +'.';
            else if (temp<2.8) reviewString = adverbs[floor(random(adjectives.length))] + ' ' + adjectives[floor(random(adjectives.length))] +'!';
            else if (temp<3.5) reviewString = adverbs[floor(random(adjectives.length))] + ' ' + adjectives[floor(random(adjectives.length))] +'.';
            else reviewString = adjectives[floor(random(adjectives.length))] + '...'
            review['text'] = uppercase(reviewString);
            review['by'] = newspapers[floor(random(8, newspapers.length))];
            book['reviews'].push(review);
            }
 
            book['price'] = '$' + floor(random(7, 11)) + '.50' // 6 <> 10
            gen['books'].push(book);
        }
        saveJSON(gen, 'book'+ n +'.json');
}