![](/img/trans.png)
[英]i' m trying to display a wordcloud image but I'm getting ValueError: We need at least 1 word to plot a word cloud, got 0
[英]I'm trying to create a wordcloud with this python code, but keeps getting error
下面的代碼是用 Jupyter notebook 的 python 編寫的。
def create_word(text):
mask = np.array (Image.open("cloud.png"))
stopwords = set (STOPWORDS)
wc= WordCloud(background_color="white",
mask= mask,
max_words=3000,
stopwords=stopwords,
repeat=True)
wc.generate(str(text))
wc.to_file("wc.png")
print("Word Cloud Saved Successfully")
path="wc.png"
display(Image.open(path))
create_wordcloud(tw_list["text"].values)
這是產生的錯誤
<ipython-input-83-57370aac7740> in create_wordcloud(text)
3
4 def create_wordcloud(text):
----> 5 mask = np.array(Image.open("cloud.png"))
6 stopwords = set(STOPWORDS)
7 wc = WordCloud(background_color="white",
~\anaconda3\lib\site-packages\PIL\Image.py in open(fp, mode, formats)
FileNotFoundError: [Errno 2] No such file or directory: 'cloud.png'
從以下 GitHub https://github.com/yalinyener/TwitterSentimentAnalysis下載 cloud.png 和 wc.png 文件
然后上傳到您的源位置
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.