Beispiel #1
0
def generate_chains( fname ):
    chains = {}
    text = reader.read_file( fname )

    words = text.split()
    i = 0
    while i < len(words) - 2:
        key = words[i] + ' ' + words[i+1]
        value = words[i+2]
        if key in chains:
            chains[ key ].append( value )
        else:
            new_list = []
            new_list.append( value )
            chains[ key ] = new_list
        i+= 1
    #print chains
    return chains
Beispiel #2
0
            elif temp > 90 and temp < 110:
                encrypted += chr(temp - 26)
            else:
                encrypted += chr(temp)
        else:
            encrypted += tempStr
    return encrypted

def decryptString (theString, key):
    return encryptString (theString, 26-int(key))


#Sengen


words = reader.get_csv_dict( 'utils/data/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():