在Python上的WordCloud中,我想合并两种语言

问题描述 投票:1回答:1

[在Python上的WordCloud中,我想将两种语言合并为一张图片(英语,阿拉伯语),但是当您看到一个正方形而不是单词时,并且当我调用Arabic_reshaper库并制作它时,我无法添加阿拉伯语读取csv文件,它向我显示了阿拉伯语言,并将英语变成正方形]

    wordcloud = WordCloud(
                          collocations = False,
                          width=1600, height=800,
                          background_color='white',
                          stopwords=stopwords,
                          max_words=150,
                          random_state=42,
                          #font_path='/Users/mac/b.TTF'
                         ).generate(' '.join(df['body_new']))
print(wordcloud)
plt.figure(figsize=(9,8))
fig = plt.figure(1)
plt.imshow(wordcloud)
plt.axis('off')
plt.show()

see her a put two languages ,but see a squares instead of words arabic enter image description here

a wont like this max two languages

enter image description here

python csv cluster-computing arabic word-cloud
1个回答
0
投票

我已经在同一个问题上苦苦挣扎了一段时间,处理它的最好方法是generate_from_frequencies()函数。您还需要正确的阿拉伯字体。 “ Shorooq”可以正常运行,并且可以免费在线获得。这是您的代码的快速修复:

© www.soinside.com 2019 - 2024. All rights reserved.