Skip to content

Commit ae4231a

Browse files
committed
Added replace_jalalah
1 parent 052ac24 commit ae4231a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arabic_reshaper.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ def get_glyph_type(target):
153153

154154
def is_haraka(target):
155155
return target in HARAKAT
156-
156+
157+
def replace_jalalah(unshaped_word):
158+
return re.sub(u'^\u0627\u0644\u0644\u0647$', u'\uFDF2', unshaped_word)
159+
157160
def replace_lam_alef(unshaped_word):
158161
list_word = list(unshaped_word)
159162
letter_before = u''
@@ -226,6 +229,7 @@ def reconstruct_word(self, reshaped_word):
226229
return u''.join(l)
227230

228231
def get_reshaped_word(unshaped_word):
232+
unshaped_word = replace_jalalah(unshaped_word)
229233
unshaped_word = replace_lam_alef(unshaped_word)
230234
decomposed_word = DecomposedWord(unshaped_word)
231235
result = u''
@@ -321,4 +325,4 @@ def reshape_sentence(sentence):
321325
for j in range(len(mixed_words)):
322326
mixed_words[j] = get_reshaped_word(mixed_words[j])
323327
words[i] = u''.join(mixed_words)
324-
return u' '.join(words)
328+
return u' '.join(words)

0 commit comments

Comments
 (0)