如何提取一篇英文文章的所有單詞

import string
fin = open(filename) 
words = []
count = 0
for line in fin:
	line = line.replace('-',' ')
	for word in line.split():
		word = word.strip(string.punctuation + string.whitespace)
		word = word.lower()
		if word not in words:
			words.append(word)
			count = count+1
			print count , ' ' , word



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章