python中不允许针对wordcloud和don';跑不动
我尝试用python制作波斯语Wordcloud。我运行包,但得到错误。我尝试使用正则表达式并从文本中删除一些unicode,但不起作用。文本是波斯语twit,我从twitter上抓取它们。 这是我的代码:python中不允许针对wordcloud和don';跑不动,python,word-cloud,Python,Word Cloud,我尝试用python制作波斯语Wordcloud。我运行包,但得到错误。我尝试使用正则表达式并从文本中删除一些unicode,但不起作用。文本是波斯语twit,我从twitter上抓取它们。 这是我的代码: import matplotlib.pyplot as plt import matplotlib as mpl %matplotlib inline from persian_wordcloud.wordcloud import PersianWordCloud, add_stop_wo
import matplotlib.pyplot as plt
import matplotlib as mpl
%matplotlib inline
from persian_wordcloud.wordcloud import PersianWordCloud, add_stop_words
from wordcloud import STOPWORDS as EN_STOPWORDS3
stopwords = EN_STOPWORDS
wordcloud = PersianWordCloud(
only_persian=True,
max_words=100,
stopwords=stopwords,
margin=0,
width=800,
height=800,
min_font_size=1,
max_font_size=500,
background_color="white"
).generate(All_Khashm_str)
plt.figure(figsize=(15,15))
image = wordcloud.to_image()
imgplot = plt.imshow(image)
plt.show()
并获取以下错误:
AssertionError Traceback (most recent call last)
<ipython-input-40-f8bfa84af8e1> in <module>
11 max_font_size=500,
12 background_color="white"
---> 13 ).generate(All_Khashm_str)
14
15
~/.local/lib/python3.6/site-packages/persian_wordcloud/wordcloud.py in generate(self, text)
142 """
143 # reshape persian words
--> 144 text = get_display(arabic_reshaper.reshape(text))
145 return self.generate_from_text(text)
146
~/.local/lib/python3.6/site-packages/bidi/algorithm.py in get_display(unicode_or_str, encoding, upper_is_rtl, base_dir, debug)
646 resolve_weak_types(storage, debug)
647 resolve_neutral_types(storage, debug)
--> 648 resolve_implicit_levels(storage, debug)
649 reorder_resolved_levels(storage, debug)
650 apply_mirroring(storage, debug)
~/.local/lib/python3.6/site-packages/bidi/algorithm.py in resolve_implicit_levels(storage, debug)
464 # only those types are allowed at this stage
465 assert _ch['type'] in ('L', 'R', 'EN', 'AN'),\
--> 466 '%s not allowed here' % _ch['type']
467
468 if _embedding_direction(_ch['level']) == 'L':
AssertionError: not allowed here
AssertionError回溯(最近一次调用)
在里面
11最大字体大小=500,
12背景颜色=“白色”
--->13).生成(所有Khashm街)
14
15
生成中的~/.local/lib/python3.6/site-packages/posian\u wordcloud/wordcloud.py(self,text)
142 """
143#重塑波斯语词汇
-->144 text=get_显示(阿拉伯语_整形器.整形(文本))
145返回self.generate_from_text(text)
146
get\u显示中的~/.local/lib/python3.6/site-packages/bidi/algorithm.py(unicode\u或\u str,编码,上限为\u rtl,基本目录,调试)
646解决\u弱\u类型(存储、调试)
647解析非特定类型(存储、调试)
-->648解析\u隐式\u级别(存储、调试)
649重新排序\u已解决\u级别(存储、调试)
650应用镜像(存储、调试)
解析隐式级别(存储、调试)中的~/.local/lib/python3.6/site-packages/bidi/algorithm.py
464#本阶段只允许使用这些类型
465在('L','R','EN','AN')中断言_ch['type']\
-->466此处不允许“%s”%\u ch['type']
467
468如果_嵌入_方向(_ch['level'])=='L':
断言者错误:此处不允许
谢谢你的帮助。这是一个bug吗?试着使用
wordcloud\u fa
库,它比其他库工作得更好。All\u Khashm\u str
在哪里???