在高音扬声器刮擦后, 我要做'形态分析'。但是会发生错误。
“处理已完成,退出代码为-1073740940(0xC0000374)”
如何修复代码? 请指教。 谢谢你的建议。
from konlpy.tag import Twitter
from collections import Counter
def get_tags(text, ntags=50):
spliter = Twitter()
nouns = spliter.nouns(text)
count = Counter(nouns)
return_list = []
for n, c in count.most_common(ntags):
temp = {'tag': n, 'count': c}
return_list.append(temp)
return return_list
def main():
text_file_name = '11.txt'
noun_count = 30
output_file_name = '6767.txt'
open_text_file = open(text_file_name, 'r',-1,"utf-8")
text = open_text_file.read()
tags = get_tags(text, noun_count)
open_text_file.close()
open_output_file = open(output_file_name, 'w',-1,"utf-8")
for tag in tags:
noun = tag['tag']
count = tag['count']
open_output_file.write('{} {}\n'.format(noun, count))
open_output_file.close()
if __name__ == '__main__':
main()