Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pyarabic/araby.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,14 @@
# ~ """ all alef like letters """
LIGUATURES_PATTERN = re.compile(u"[" + u"".join(LIGUATURES) + u"]", re.UNICODE)
# ~ """ all liguatures pattern """
TOKEN_PATTERN = re.compile(u"([^\w\u0670\u064b-\u0652']+)", re.UNICODE)
TOKEN_PATTERN = re.compile(r"([^\w\u0670\u064b-\u0652']+)", re.UNICODE)
# ~ """ pattern to tokenize a text"""
TOKEN_PATTERN_SPLIT = re.compile(u"([\w\u0670\u064b-\u0652']+)", re.UNICODE)
TOKEN_PATTERN_SPLIT = re.compile(r"([\w\u0670\u064b-\u0652']+)", re.UNICODE)
# ~ """ pattern to tokenize a text with positions"""
TOKEN_REPLACE = re.compile(u'\t|\r|\f|\v| ')

# Arabic string
ARABIC_STRING = re.compile(u"([^\u0600-\u0652%s%s%s\s\d])" \
ARABIC_STRING = re.compile(r"([^\u0600-\u0652%s%s%s\s\d])" \
% (LAM_ALEF, LAM_ALEF_HAMZA_ABOVE, LAM_ALEF_MADDA_ABOVE), re.UNICODE)
# Arabic range
ARABIC_RANGE = re.compile(
Expand Down Expand Up @@ -1234,7 +1234,7 @@ def reduce_tashkeel(text):
u"%s(?=%s)" % (FATHA, ALEF), \
# delete fatha from yeh and waw if they are in the word begining.

u"(?<=\s(%s|%s))%s" % (WAW, YEH, FATHA), \
r"(?<=\s(%s|%s))%s" % (WAW, YEH, FATHA), \
# delete kasra if preceded by Hamza below alef.

u"(?<=%s)%s" % (ALEF_HAMZA_BELOW, KASRA), \
Expand Down Expand Up @@ -1447,7 +1447,7 @@ def autocorrect(text):
@rtype: unicode
"""
## HARAKAT
text = re.sub(u"(?<=[\s\d])([%s])+"%(TASHKEEL_STRING),"",text, re.UNICODE)
text = re.sub(r"(?<=[\s\d])([%s])+"%(TASHKEEL_STRING),"",text, re.UNICODE)
text = re.sub(u"^([%s])+"%(TASHKEEL_STRING),"",text , re.UNICODE)
# tanwin on alef
text = re.sub(ALEF+FATHATAN, FATHATAN + ALEF,text , re.UNICODE)
Expand Down
2 changes: 1 addition & 1 deletion pyarabic/araby_const.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,4 @@
#~ """ all alef like letters """
LIGUATURES_PATTERN = re.compile(u"["+u"".join(LIGUATURES)+u"]", re.UNICODE)
#~ """ all liguatures pattern """
TOKEN_PATTERN = re.compile(u"[^\w\u064b-\u0652']+", re.UNICODE)
TOKEN_PATTERN = re.compile(r"[^\w\u064b-\u0652']+", re.UNICODE)
4 changes: 2 additions & 2 deletions pyarabic/trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def segment_language(text):
resultlist.append(('latin', actual_text))
arabic = True
actual_text = k
elif re.search(u"[\s\d\?, :\!\(\)]", k):
elif re.search(r"[\s\d\?, :\!\(\)]", k):
actual_text += k
else:
if arabic:
Expand Down Expand Up @@ -515,7 +515,7 @@ def decode_tashkeel(word, marks, method = "ascii"):
# test detect language
text =u"""السلام عليكم how are you, لم اسمع أخبارك منذ مدة, where are you going"""
print(arepr(segment_language(text)))
text_out= delimite_language(text, start='\RL{', end="}")
text_out= delimite_language(text, start=r'\RL{', end="}")
print(text_out.encode('utf8'))
text_out= delimite_language(text, start="<arabic>", end="</arabic>")
print(text_out.encode('utf8'))