【发布时间】:2018-07-24 15:37:24
【问题描述】:
我已经编写了创建频率表的代码。但它正在打破ext_string = document_text.read().lower( 的行。我什至尝试了除以捕获错误,但没有帮助。
import re
import string
frequency = {}
file = open('EVG_text mining.txt', encoding="utf8")
document_text = open('EVG_text mining.txt', 'r')
text_string = document_text.read().lower()
match_pattern = re.findall(r'\b[a-z]{3,15}\b', text_string)
for word in match_pattern:
try:
count = frequency.get(word,0)
frequency[word] = count + 1
except UnicodeDecodeError:
pass
frequency_list = frequency.keys()
for words in frequency_list:
print (words, frequency[words])
【问题讨论】:
标签: python api sentiment-analysis vader