WordCloud 한글 폰트 문제 해결 과정에 대한 글 입니다.
from wordcloud import WordCloud
import matplotlib.pyplot as plt
%matplotlib inline
wordcloud = WordCloud(font_path=os.path.join(DATA_IN_PATH, 'NanumGothic.ttf')).generate(" ".join(train_review))
plt.figure(figsize=(10, 8))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
plt.show()
🤬Error
Output exceeds the size limit. Open the full output data in a text editor
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
c:\Users\user\Desktop\github\NLP\NLP.ipynb Cell 138 in <cell line: 6>()
3 import matplotlib.pyplot as plt
4 get_ipython().run_line_magic('matplotlib', 'inline')
----> 6 wordcloud = WordCloud(font_path=os.path.join(DATA_IN_PATH, 'NanumGothic.ttf')).generate(" ".join(train_review))
8 plt.figure(figsize=(10, 8))
9 plt.imshow(wordcloud, interpolation='bilinear')
File c:\Users\user\anaconda3\envs\nlpproject\lib\site-packages\wordcloud\wordcloud.py:639, in WordCloud.generate(self, text)
624 def generate(self, text):
625 """Generate wordcloud from text.
626
627 The input "text" is expected to be a natural text. If you pass a sorted
(...)
637 self
638 """
--> 639 return self.generate_from_text(text)
File c:\Users\user\anaconda3\envs\nlpproject\lib\site-packages\wordcloud\wordcloud.py:621, in WordCloud.generate_from_text(self, text)
604 """Generate wordcloud from text.
605
606 The input "text" is expected to be a natural text. If you pass a sorted
(...)
618 self
...
251 )
252 else:
253 load_from_bytes(font)
OSError: cannot open resource
wordcloud = WordCloud(font_path=os.path.join(DATA_IN_PATH, 'NanumGothic.ttf')).generate(" ".join(train_review))
wordcloud = WordCloud(font_path=os.path.join(DATA_IN_PATH, 'NanumGothic.ttf')).generate(" ".join(train_review))
plt.figure(figsize=(10, 8))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
plt.show()