from PIL import Image
 import numpy as np
 from wordcloud import WordCloud
    
 text = ' '
 with open("kakaoTalk.csv", "r", encoding="utf-8") as f:
     lines = f.readlines()
     for line in lines:
         text += line.replace('ㅋ', '')\
             .replace('ㅎ', '')\
             .replace('ㅜ', '')\
             .replace('ㅠ', '')\
             .replace('이모티콘', '')\
             .replace('사진', '')\
    
 mask = np.array(Image.open('cloud.png'))
 wc = WordCloud(font_path='/System/Library/Fonts/AppleSDGothicNeo.ttc', background_color="white", mask=mask)
 wc.generate(text)
 wc.to_file("result_masked.png")
     
댓글남기기