'''
Created on Apr 4, 2011

@author: ola
'''

import random

def create_content():
    """
    return a dictionary used for generating random sentences
    """
    adjectives = ["<color>","slimy","wonderful","beautiful","obese","teeny","<adj> , <adj>"]
    colors = ["green","red","yellow","blue","maroon"]
    rules = {"<color>":colors, "<adj>":adjectives}
    
    return rules


def expand(sentence,rules):
    """
    expand sentence using rules as source of meta-words
    """
    sent = ""
    for w in sentence.split():
        if w.startswith("<"):
            chosen = random.choice(rules[w])
            sent += expand(chosen,rules) +" "
        else:
            sent += w + " "
    return sent.strip()

def create():
    rules = create_content()
    print expand("the <adj> dog ate the <adj> bone",rules)
    print expand("the <color> house was a <adj> edifice", rules)

if __name__ == "__main__":
    create()