National Novel Generation Month 2016 Reflection


National Novel Generation Month aka NaNoGenMo is a month long contest to write code to generate a novel of 50k+ words.

Before I start talking about my plans for this year, I thought it would be a good idea to reflect on my previous efforts. In last year's contest I created two novels(!):

Banned Books Censored

The statement of intent on NaNoGenMo: github.com/NaNoGenMo/2016/issues/94.

I redacted the following books (via Project Gutenberg) listed in Anne Haight's Banned Books (booked banned by authorities or religious organisations at some point in time). The numbers relate to the Project Gutenberg book ID:

The code to do these novels can be found at github.com/booyaa/fuckcensorship. The language I used was Bash. The main crux of the code is to replace non-whitespace characters with Unicode FULL BLOCK character (█):

for book in $FOLDER_IN/*.txt; do
    echo "Processing $book..."
    FILE_OUT=$FOLDER_OUT/$(basename "$book" .txt).censored.txt
    $SED_EXEC  's/\S/\xE2\x96\x88/g' < "$book" > "$FILE_OUT"
done

Here's a sample of The Odyssey.

█████████████

██████████ ██ ██ ████ ███ ██████ ██ ██████████ ██ █████████ ██ ██
███████████ ██ ██ ███████ ████ ████ ██ ██ ███████ █████ ███ ███ ███
████ █████ ██ ████ ███ ████ ███████ ███████████ ██████ ████ ███ ████
███████ █████████ ██ ███ ██████████ ██ ████ ███████████ ███████ ███
██████████ █████████ █████ █████████ ██████████ █████████ ██ ████ ███
█████ ███ ███████ ███ ███████ █████ █████ ████ ██ ██ ██████ ██ ████
██ █████ ██████████ █████████ █████ ██ ███ ████ ██ ██ █████ ██████
███ ███████ ██ ████████

The collection of censored books can be found on github.com/booyaa/bannedbookscensored/tree/master/censored

A book of November

This novel was a simple concept, you need to write 1,666 words a day to hit the 50k target for NaNoWriMo. So why not write chapter consisting of the number of the day for the month i.e. the 1st of the month would be one?

The code to create this novel can be found at github.com/booyaa/nanogenmo2016. The language I used to write the code was Rust. The code snippet I'm particular proud of is my sentence length variation func.

fn get_sentence(word: &str) -> (String, u64) {

    let mut rng = rand::thread_rng();
    let faces = Range::new(1, 9);
    let num = dice(&faces, &mut rng);
    let sentence_sizes = match num {
        1 | 4 | 7 => 5,
        2 | 5 | 8 => 7,
        3 | 6 | 9 => 13,
        _ => 0,
    };

    let mut sentence = String::new();
    for i in 0..sentence_sizes {
        sentence.push_str(&format!("{} ", word));
    }
    sentence = sentence.trim().to_string();
    sentence.push_str(". ");

    (sentence, sentence_sizes)
}

Admittedly the effect is a bit subtle to be noticed the first time around. Also in reflection I should've capitalized the start of the sentence.

Here's a sample of the novel (brace yourself)

one

one one one one one one one one one one one one one. one one one one one. one one one one one one one. one one one one one one one. one one one one one. one one one one one. one one one one one. one one one one one one one. one one one one one. one one one one one one one. one one one one one one one. one one one one one one one. one one one one one one one. one one one one one one one one one one one one one. one one one one one one one one one one one one one. one one one one one one one. one one one one one. one one one one one one one one one one one one one.

Summary

I didn't spend the whole month writing code to write a novel, but the exercise was a lot of fun. Were my novels any good? No not really, they should be filed under the joke or stunt category.

However, don't let my efforts convince you that it's not a worth while project. Here's some of my favourites from last year:



Tweet