Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for c in word:
if previous and not previous == araby.ALEF:
#--------- add Harakat before letter
if c in (araby.ALEF, araby.ALEF_MAKSURA, araby.TEH_MARBUTA,):
marks.pop()
marks.append(araby.FATHA)
elif c in (araby.WAW, araby.WAW_HAMZA):
marks.pop()
marks.append(araby.DAMMA)
elif c in( araby.YEH , araby.YEH_HAMZA ):
marks.pop()
marks.append(araby.KASRA)
#--------- add Harakat before letter
if c in (araby.ALEF_HAMZA_BELOW):
marks.append(araby.KASRA)
elif previous in (araby.ALEF_HAMZA_BELOW, araby.ALEF_HAMZA_ABOVE):
marks.append(araby.SUKUN)
elif previous in (araby.ALEF, araby.YEH, araby.WAW):
if c == araby.YEH_HAMZA :
marks.append(araby.KASRA)
else:
marks.append(araby.NOT_DEF_HARAKA)
previous = c
#print len(word) ,len(marks)
#print marks
return araby.joint(word, u"".join(marks))
def highlight_diacritics_html(self, text):
"""
Highlight dfiactitics in the HTML text.
@param text: the given text
@type text: unicode.
@return: the result as HTML.
@rtype: unicode.
"""
hight_text = u""
lefttag = u"<span class="tashkeel">"
righttag = u"</span>"
for i in range(len(text)):
if text[i] in (araby.FATHA, araby.DAMMA, araby.KASRA, araby.SUKUN):
if (i>0 and text[i-1] not in (araby.ALEF,
araby.ALEF_HAMZA_ABOVE, araby.WAW_HAMZA, araby.ALEF_MADDA,
araby.DAL, araby.THAL, araby.WAW, araby.REH, araby.ZAIN,
araby.SHADDA)) and (i+1%s"%text[i]
hight_text += u"".join([lefttag, " ", text[i], righttag])
else:
hight_text += text[i]
return hight_text
@staticmethod
def get_in_stem_variants(stem, enclitic):
""" return modified forms of input stem"""
list_stem = []
if enclitic:
if stem.endswith(ar.TEH + ar.MEEM + ar.WAW):
list_stem.append(stem[:-1])
elif stem.endswith(ar.WAW):
list_stem.append(stem + ar.ALEF)
elif stem.endswith(ar.ALEF):
list_stem.append(stem[:-1] + ar.ALEF_MAKSURA)
if stem.startswith(ar.ALEF_MADDA):
# االبداية بألف مد
list_stem.append(ar.ALEF_HAMZA_ABOVE + \
ar.ALEF_HAMZA_ABOVE + stem[1:])
list_stem.append(ar.HAMZA + ar.ALEF + stem[1:])
return list_stem
@staticmethod
_F = FATHA
_D = DAMMA
_K = KASRA
_S = SUKUN
_A = ALEF_HARAKA
_W = WAW_HARAKA
_Y = YEH_HARAKA
_AH = ALEF_HARAKA
_YH = YEH_HARAKA
_WH = WAW_HARAKA
_AYH = ALEF_YEH_HARAKA
_AWH = ALEF_WAW_HARAKA
_YHALT = ALTERNATIVE_YEH_HARAKA
#HAMZAT
_AHA = ALEF_HAMZA_ABOVE
_AHB = ALEF_HAMZA_BELOW
_AM = ALEF_MADDA
_YHA = YEH_HAMZA
_WHA = WAW_HAMZA
_HZ = HAMZA
INITIAL_TAHMEEZ_TABLE = {_S:_HZ, _F:_AHA, _D:_AHA, _K:_AHB, _AH:_AM ,
_WH:_AHA, _YH:_AHB, _YHALT:_AHB}
MIDDLE_TAHMEEZ_TABLE = {
_S: {_S:_HZ, _F:_AHA, _D:_WHA, _K:_YHA, _AH:_AHA, _WH:_WHA, _YH:_YHA },
_F: {_S:_AHA, _F:_AHA, _D:_WHA, _K:_YHA, _AH:_AHA, _WH:_WHA, _YH:_YHA },
_D: {_S:_WHA, _F:_WHA, _D:_WHA, _K:_YHA, _AH:_WHA, _WH:_WHA, _YH:_YHA },
_K: {_S:_YHA, _F:_YHA, _D:_YHA, _K:_YHA, _AH:_YHA, _WH:_YHA, _YH:_YHA },