Copia

Written on January 8, 2016

The copia is a program that creates new sentences from your input. When using copia, please input ONE or TWO nouns, ONE verb, and any number of adjectives or adverbs.

## Written by Sam Klein ##
#
### IMPORT ###
#
import urlgrabber
import shutil
from colored import fore, back, style
### URL ###
#
wiki = 'http://en.wiktionary.org/wiki/'
#
### LISTS ###
#
noun = []
new_nouns = []
verb = []
new_verbs = []
adj = []
new_adjs = []
adverb = []
new_adverb = []
#
### VARIABLES ###
created_word = "nothing"
#
### COUNTS ###
#
array_count = 0
#
### FUNCTIONS ###
#
## REFRESH FUNCTION
#
def refresh_var():
	global x, new_word
	x = 0
	new_word = "start"
	print "Type 1 to skip."
#
## DOWNLOAD PAGE FROM WIKI AND MOVE FILE TO ARBITRARY FOLDER
#
def grab_new_wiki(strg):
	global created_word, wiki, newfile
	new_wiki = wiki + strg
	urlgrabber.urlgrab(new_wiki, filename=strg, timeout = 2, retry = 2, reget = 'simple')
	shutil.move(strg, "dump")
#
##
#
def grab_new_word_from_array(strg):
	global noun, verb, adj, adverb
	if not strg:
		print ""
	else:
		for i in range(len(strg)):
			grab_new_wiki(strg[i])
	
#
##
### INIT ###
##
#
refresh_var()

while ((new_word != "1") and (x <= 1)):
	print (fore.YELLOW + back.BLACK + style.BOLD + "Please add noun:" + style.RESET)
	new_word = raw_input()
	if (new_word != "1"):
		noun.insert(x, new_word)
		x = x + 1
	else:
		if not noun:
			print "The noun dictionary is empty."
		else:
			if (len(noun) > 1):
				noun.pop()
			else:
				print "Done."

refresh_var()
	
while ((new_word != "1") and (x <= 0)):
	print (fore.CYAN + back.BLACK + style.BOLD + "Please add verb:" + style.RESET)
	new_word = raw_input()
	if (new_word != "1"):
		verb.insert(x, new_word)
		x = x + 1
	else:
		if not verb:
			print "The verb dictionary is empty."
		else: 
			verb.pop()
		
refresh_var()
	
while (new_word != "1"):
	print (fore.LIGHT_BLUE + back.BLACK + style.BOLD + "Please add adjective or 1 when done:" + style.RESET)
	new_word = raw_input()
	adj.insert(x, new_word)
	x = x + 1
	
refresh_var()

while (new_word != "1"):
	print (fore.GREEN + back.BLACK + style.BOLD + "Please add adverb or 1 when done:" + style.RESET)
	new_word = raw_input()
	adverb.insert(x, new_word)
	x = x + 1

adj.pop()
adverb.pop()

print noun
print verb
print adj
print adverb

grab_new_word_from_array(noun)
grab_new_word_from_array(verb)
grab_new_word_from_array(adj)
grab_new_word_from_array(adverb)

Take me home.

Check out the archive.