コード例 #1
0
from random import random
import reader_v2 as reader


words = reader.get_csv_dict( 'wordlist.csv' )
nouns = words['nouns']
verbs = words['verbs']
adjs = words['adjectives']
advbs = words['adverbs']
articles = ['a','an','the','one']

#takes list of words, returns 1 randomly chosen word
def one_of( g ):
    return g[ int( random() * len(g) ) ]


#wrapper functions for readability
def noun():
    return one_of( nouns )
def verb():
    return one_of( verbs )
def adjective():
    return one_of( adjs )
def article():
    return one_of( articles )
def adverb():
    return one_of( advbs )


def adjectives():
    if random() < .5: