#
# µû¶óÇÏ¸ç ¹è¿ì´Â ÆÄÀ̽ã°ú µ¥ÀÌÅÍ°úÇÐ(»ý´ÉÃâÆÇ»ç 2020)
# LAB 8-4 ÆÄÀÏ¿¡¼ Áߺ¹µÇÁö ¾ÊÀº ´Ü¾îÀÇ °³¼ö ±¸Çϱâ, 212ÂÊ
#
# ´Ü¾î¿¡¼ ±¸µÎÁ¡À» Á¦°ÅÇÏ°í ¼Ò¹®ÀÚ·Î ¸¸µç´Ù.
def process(w):
output =""
for ch in w:
if ch.isalpha() :
output += ch
return output.lower()
words = set() # Áߺ¹À» ¹æÁöÇϱâ À§ÇØ ÁýÇÕ ÀÚ·áÇü¿¡ ´Ü¾î¸¦ ³ÖÀÚ
fname = input("ÀÔ·Â ÆÄÀÏ À̸§: ")
file = open(fname, "r") # ÆÄÀÏÀ» ¿¬´Ù
# ÆÄÀÏÀÇ ¸ðµç ÁÙ¿¡ ´ëÇÏ¿© ¹Ýº¹ÇÑ´Ù.
for line in file:
lineWords = line.split()
for word in lineWords:
words.add(process(word)) # ´Ü¾î¸¦ ÁýÇÕ¿¡ Ãß°¡ÇÑ´Ù.
print("»ç¿ëµÈ ´Ü¾îÀÇ °³¼ö =", len(words))
print(words)