Create wordcloud with ArabicΒΆ

Generating a wordcloud from Arabic text

Dependencies: - bidi.algorithm - arabic_reshaper

Dependencies installation: pip install python-bidi arabic_reshape


<wordcloud.wordcloud.WordCloud object at 0x7f4b79679fd0>

import os
import codecs
from wordcloud import WordCloud
import arabic_reshaper
from bidi.algorithm import get_display

# get data directory (using getcwd() is needed to support running example in generated IPython notebook)
d = os.path.dirname(__file__) if "__file__" in locals() else os.getcwd()

# Read the whole text.
f =, 'arabicwords.txt'), 'r', 'utf-8')

# Make text readable for a non-Arabic library like wordcloud
text = arabic_reshaper.reshape(
text = get_display(text)

# Generate a word cloud image
wordcloud = WordCloud(font_path='fonts/NotoNaskhArabic/NotoNaskhArabic-Regular.ttf').generate(text)

# Export to an image

Total running time of the script: ( 0 minutes 1.006 seconds)

Gallery generated by Sphinx-Gallery