我是一个刚开始学习python的韩国人。我正在用韩文做wordcloud。我想我做了我所教的一切。但是我得到了这个我无法解决的错误。请帮我。
from wordcloud import WordCloud
from collections import Counter
from konlpy.tag import Okt
这是输入
text=''
with open("./res/대한민국헌법.txt", encoding="utf-8") as f:
text = f.read()
nlp =Okt()
nouns =nlp.nouns(text)
# print(nouns)
# print("-" * 30)
words=[]
for n in nouns:
if len(n) >1:
words.append(n)
# print(words)
print("-" * 30)
#Counter 객체를 통해 리스트 원소들의 빈도수 계산
count =Counter(words)
most=count.most_common(100)
# print(most)
print("-" * 30)
tags={}
for t in most:
n, c= t
tags[n]=c
print(tags)
wc= WordCloud(font_path="NanumGothic", width=1200, height=800,
scale=2.0, max_font_size=250)
wc.generate_from_frequencies(tags) # <- this is where I got the error from
wc.to_file("대한민국헌법-주요단어.png")
这是输出
Trackback(最近的最新通话):文件“ D:\ Hyeokjun \ 01-파이썬기초,데이터화\ 09-데이터데이터-데이터-가로++++++++++워드\워드\파이썬\파이썬\파이썬\파이썬\파이썬\파이썬\파이썬\파이썬\파이썬\ 09강\ section09 \ section09 \ 01 \ 01 \ 01 .numeric.py”,第 40 行,在 wc.generate_from_frequencies(tags) 文件“C:\Users\newjh\AppData\Local\Programs\Python\Python37\lib\site-packages\wordcloud\wordcloud.py”,第 496 行,在 generate_from_frequencies font = ImageFont.truetype(self.font_path, font_size) 文件“C:\Users\newjh\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\ImageFont.py”中,第 648 行,在 truetype 中返回 freetype(字体)文件“C:\Users\newjh\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\ImageFont.py”,第 645 行,在 freetype 中返回 FreeTypeFont(字体,大小,索引,编码,layout_engine)文件“C:\Users\newjh\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\ImageFont.py",第 194 行,在init font, size, index, encoding, layout_engine=layout_engine OSError: cannot open resource [Finished in 5.9s]