Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_mankous(vocalized):
if vocalized.endswith( araby.YEH ):
#strip last yeh
return vocalized[:-1] + araby.KASRATAN;
else:
print (u"*********%s"%vocalized).encode('utf8');
#exit();
self.conj_display.add(tense, vconst.PronounHuma,
YEH+conj_antuma[1:])
conj_antum = self.conjugate_tense_pronoun(tense,
vconst.PronounAntum)
self.conj_display.add(tense, vconst.PronounAntum,
conj_antum)
self.conj_display.add(tense, vconst.PronounHum,
YEH+conj_antum[1:])
conj_antunna = self.conjugate_tense_pronoun(tense,
vconst.PronounAntunna)
self.conj_display.add(tense, vconst.PronounAntunna,
conj_antunna)
self.conj_display.add(tense, vconst.PronounHunna,
YEH+conj_antunna[1:])
elif tense == vconst.TenseImperative or \
tense == vconst.TenseConfirmedImperative:
for pron in vconst.ImperativePronouns:
conj = self.conjugate_tense_pronoun(tense, pron)
self.conj_display.add(tense, pron, conj)
if not self.transitive:
for tense in vconst.TablePassiveTense:
for pron in vconst.PronounsTableNotPassiveForUntransitive:
self.conj_display.add(tense, pron, u"")
# if the result is not diplyed directely on the screen, we return it
result = self.conj_display.display(self.conj_display.mode,
listtense)
if result:
return result
def decode_tenses(field):
"""
Decode tenses field
"""
all=False;
past=False;
future=False;
passive=False;
imperative=False;
future_moode=False;
confirmed=False;
if field==u"يعملان":
all=True;
else:
if field.find(araby.YEH)>=0:
past=True;
if field.find(araby.AIN)>=0:
future=True;
if field.find(araby.MEEM)>=0:
imperative=True;
if field.find(araby.LAM)>=0:
passive=True;
if field.find(araby.ALEF)>=0:
future_moode=True;
if field.find(araby.NOON)>=0:
confirmed=True;
return (all, past, future, passive, imperative, future_moode, confirmed);
def decode_tenses(field):
all=False;
past=False;
future=False;
passive=False;
imperative=False;
future_moode=False;
confirmed=False;
if field==u"يعملان":
all=True;
else:
if field.find(araby.YEH)>=0:
past=True;
if field.find(araby.AIN)>=0:
future=True;
if field.find(araby.MEEM)>=0:
imperative=True;
if field.find(araby.LAM)>=0:
passive=True;
if field.find(araby.ALEF)>=0:
future_moode=True;
if field.find(araby.NOON)>=0:
confirmed=True;
return (all, past, future, passive, imperative, future_moode, confirmed);
def get_enclitic_variant(word, enclitic):
"""
Get the enclitic variant to be joined to the word.
For example: word = أرجِهِ , enclitic = هُ.
The enclitic is convert to HEH+ KAsra.
اعبارة في مثل أرجه وأخاه إلى يم الزينة
@param word: word found in dictionary.
@type word: unicode.
@param enclitic: first level suffix vocalized.
@type enclitic: unicode.
@return: variant of enclitic.
@rtype: unicode.
"""
#if the word ends by a haraka
if enclitic == ar.HEH+ar.DAMMA and (word.endswith(ar.KASRA)\
or word.endswith(ar.YEH)):
enclitic = ar.HEH + ar.KASRA
return enclitic
def get_verb_info(self, verb_tuple):
"""
Get verb information
"""
# get verb subclass
verb_nm = araby.strip_tashkeel(verb_tuple['vocalized'])
verb_class = ""
if verb_nm.startswith(araby.WAW):
verb_class= "W1W" #"Mithal_W"
elif verb_nm[-2:-1] ==araby.ALEF: # before last char
if verb_tuple['future_type'] in (araby.DAMMA, u"ضمة"):
verb_class= "W2W" #"Adjwaf_W"
elif verb_tuple['future_type'] in (araby.KASRA, u"كسرة"):
verb_class= "W2Y" #"Adjwaf_Y"
elif verb_nm[-1:] in (araby.YEH, araby.ALEF_MAKSURA):
verb_class= "W3Y" #"Naqis_Y"
elif verb_nm[-1:] == araby.ALEF:
verb_class= "W3W" #"Naqis_W"
elif araby.SHADDA in (verb_tuple['vocalized']):
verb_class= "Dbl" # doubled
else:
verb_class = "-"
# the passive tenses dont take object suffix, only with double transitie verbs
tags = "V."+verb_class+"."
if verb_tuple['transitive']:
tags +="T"
else:
tags +="I"
if verb_tuple['double_trans']:
self.conj_display.add(tense, vconst.PronounHuma,
conj_huwa[:-2]+YEH_HAMZA+FATHA+ALEF)
## conj_hum=self.conjugate_tense_pronoun(tense,
# vconst.PronounHum)
self.conj_display.add(tense, vconst.PronounHum,
conj_huwa[:-2]+YEH_HAMZA+DAMMA+WAW+ALEF)
else :
self.conj_display.add(tense, vconst.PronounHya,
conj_huwa+TEH+SUKUN)
self.conj_display.add(tense, vconst.PronounHuma_f,
conj_huwa+TEH+FATHA+ALEF)
self.conj_display.add(tense, vconst.PronounHuma,
conj_huwa+ALEF)
if conj_huwa.endswith(KASRA+YEH+FATHA):
self.conj_display.add(tense, vconst.PronounHum,
conj_huwa[:-3]+DAMMA+WAW+ALEF)
else:
self.conj_display.add(tense, vconst.PronounHum,
conj_huwa[:-1]+DAMMA+WAW+ALEF)
elif tense in (vconst.TenseFuture, vconst.TensePassiveFuture,
vconst.TenseJussiveFuture, vconst.TenseSubjunctiveFuture,
vconst.TenseConfirmedFuture, vconst.TensePassiveJussiveFuture,
vconst.TensePassiveSubjunctiveFuture,
vconst.TensePassiveConfirmedFuture):
conj_ana = self.conjugate_tense_pronoun(tense,
vconst.PronounAna)
self.conj_display.add(tense, vconst.PronounAna,
conj_ana)
conj_anta = self.conjugate_tense_pronoun(tense,
u'آوب':[u'ءاوب'],
u'آوى':[u'أءوى'],
u'آيد':[u'ءايد'],
u'آيس':[u'أءيس'],
}
STANDARD_REPLACEMENT=[
#-تحويل همزة القطع على الألف بعدها فتحة
#وهمزة القطع على الألف بعدها سكون إلى ألف ممدودة
( u"".join([ALEF_HAMZA_ABOVE, FATHA, ALEF]), ALEF_MADDA)
, ( u"".join([ALEF_MADDA, FATHA]), ALEF_MADDA)
, ( u"".join([ALEF_MADDA, ALEF]), ALEF_MADDA)
, ( u"".join([ALEF_HAMZA_ABOVE, FATHA, ALEF_HAMZA_ABOVE, SUKUN]), ALEF_MADDA)
, ( u"".join([ALEF_HAMZA_ABOVE, FATHA, ALEF_HAMZA_ABOVE, FATHA]), ALEF_MADDA)
, ( u"".join([ALEF_HAMZA_ABOVE, DAMMA, WAW_HAMZA, SUKUN]), ALEF_HAMZA_ABOVE+DAMMA+WAW)
, ( u"".join([YEH, SHADDA, FATHA, ALEF_MAKSURA]), YEH+SHADDA+FATHA+ALEF)
# إدغام النون الساكنة
, ( u"".join([NOON, SUKUN, NOON]), NOON+SHADDA)
# إذا كان الحرف الأول ساكنا وبعده شدة، ثم أضيفت إليه الألف
, ( u"".join([SUKUN, SHADDA]), SHADDA)
## معالجة ألف التفريق
, ( ALEF_WASLA, ALEF)
## معالجة ألف التفريق
, ( ALEF_MAMDUDA, 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))