1

当我创建孟加拉文字云时,我面临孟加拉字体问题。问题详细信息和代码如下所示。请帮我解决这个问题。

from os import path
import numpy as np
from PIL import Image
from wordcloud import WordCloud, STOPWORDS
from bnlp.corpus import stopwords
import bangla
import unicodedata
file = open("Dataset/banglaText.txt", "r", encoding='UTF-8')
text = file.read()
#print(text)

# create numpy araay for wordcloud mask image
mask = np.array(Image.open(path.join("cloud.png")))
# create set of stopwords
stopwords = set(stopwords())
#custome unicode
rgx = r"[\u0980-\u09FF]+"
#create wordcloud object
wc = WordCloud(background_color="white",
               mask=mask,
               stopwords = stopwords,
               font_path="font/balooda.ttf",
               regexp=rgx
           )
# generate wordcloud
wc.generate(text)
# save to wordcloud image
result = wc.to_file(path.join("wordCloudBangla.png"))

图像显示中的字体中断

4

0 回答 0