Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MostafaRabia/59cce25e559b5af6cea3df30b297e1cc to your computer and use it in GitHub Desktop.
Save MostafaRabia/59cce25e559b5af6cea3df30b297e1cc to your computer and use it in GitHub Desktop.
# -*- coding: UTF8 -*-
# Tested on Python 3.6.1
# install: pip3 install --upgrade arabic-reshaper
from arabic_reshaper import ArabicReshaper
# install: pip3 install python-bidi
from bidi.algorithm import get_display
import sys
text_to_be_reshaped = sys.argv[1]
configuration = {
'use_unshaped_instead_of_isolated': True,
# 'delete_harakat': True, # لحذف التشكيل من الكلام
# 'delete_tatweel': True, # لحذف ال ـــــ من الكلام
}
resharper = ArabicReshaper.reshape(configuration=configuration)
reshaped_text = ArabicReshaper.reshape(text_to_be_reshaped)
print(get_display(reshaped_text))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment