import os

if os.path.exists('tags.txt'):
	os.remove('tags.txt')

with open('text.txt', 'r') as input_file:
	with open('tags.txt', 'a') as output_file:
		for line in input_file:
			for word in line.split():
				if (word == '.PER'):
					word = word.replace(word, 'P')
					output_file.write(word + ' ')
				elif (word == ',COM'):
					word = word.replace(word, 'C')
					output_file.write(word + ' ')
				elif(word == '?QUE'):
					word = word.replace(word, 'Q')
					output_file.write(word + ' ')
				elif(word == '<NUM>'):
					word = word.replace(word, 'N')
					output_file.write(word + ' ')
				else:
					word = word.replace(word, 'S')
					output_file.write(word + ' ')
