git.fiddlerwoaroof.com
a_an_checker
9e63ae9a
 #!/usr/bin/python
 
 import fileinput
 
 a = fileinput.FileInput()
 
 def window_iterate(sequence, width=2, begin=0):
 	while begin < len(sequence):
 		result = sequence[begin:begin+width]
 
 		while len(result) < width: result.append('')
 
 		yield result
 		begin += 1
 
 for line in a:
 	line = line.split()
 
 	out = []
 	for window in window_iterate(line):
 		if window[0] in set(['a', 'an']):
7dbb0c56
 			if any(window[1].startswith(vowel) for vowel in 'aeiou'):
 				if window[0] != 'an':
 					if raw_input('change article in %r? ' % ' '.join(window)).lower().startswith('y'):
 						window[0] = 'an'
9e63ae9a
 			else:
7dbb0c56
 				if window[0] != 'a':
 					if raw_input('change article in %r? ' % ' '.join(window)).lower().startswith('y'):
 						window[0] = 'a'
9e63ae9a
 		out.append(window[0])
 	print(' '.join(out))