#!/usr/bin/env python
# -*- coding: utf-8 -*-

import string
from time import strftime

def append_new_end(word,user_end):
	space_count = word.count('~') # count number of placeholders
	if space_count > 0:			
		total_word = word[:-space_count] + user_end # supplied from raw input
	else:
		total_word = word
		
	return total_word
	
def create_updated_array(text_complete,text_new,number_sentences):	
	

	
	
def print_output(text_complete,text_orig,number_sentences):
	sentence = 0
	while sentence < number_sentences:
		contained = [x for x in text_complete[sentence] if x not in text_orig[sentence]]
		print
		print "Original Sentence: " ,
		write_output(strftime("%Y-%m-%d %H:%M:%S"))
		write_output('\n')
		write_output("Original Sentence: ")
		write_output('\n')
		for each in text_orig[sentence]:
			print each,
			write_output(each.encode('utf-8') + ' '),
		print
		write_output('\n')
		print
		write_output("User Completed Sentence: ")
		write_output('\n')
		print "User completed text: " ,
		for each in text_complete[sentence]:
			print each,
			write_output(each.encode('utf-8') + ' '),
		print
		print
		write_output('\n')
		write_output("User Mistakes: ")
		write_output('\n')
		print "User Mistakes: " 
		for each in contained:
			print each
			write_output(each.encode('utf-8') + ' '),
		print
		print

		
		sentence += 1
		
		
def write_output(input_text):
	with open('output.txt', 'a') as f:
		f.write(input_text)
	
	
	
	
		

sentence = 0
	while sentence < number_sentences:
		word = 0
		
		print
		print text_new[sentence]	
		print	
		while word < len(text_new[sentence]):	
			user_end = raw_input(text_new[sentence][word].encode('utf-8') + ' ')	
			total_word = append_new_end(text_new[sentence][word],user_end)
			total_word.encode('utf-8')
			text_complete[sentence].append(total_word)
			word += 1
		sentence += 1	
	return text_complete