diff --git a/pyarabic/araby.py b/pyarabic/araby.py index 0476a67..e79de32 100644 --- a/pyarabic/araby.py +++ b/pyarabic/araby.py @@ -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( @@ -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), \ @@ -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) diff --git a/pyarabic/araby_const.py b/pyarabic/araby_const.py index 5abb204..5b61261 100644 --- a/pyarabic/araby_const.py +++ b/pyarabic/araby_const.py @@ -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) diff --git a/pyarabic/trans.py b/pyarabic/trans.py index 965234a..0f8fae7 100644 --- a/pyarabic/trans.py +++ b/pyarabic/trans.py @@ -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: @@ -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="", end="") print(text_out.encode('utf8'))