Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.future_type = ar_verb.get_future_type_by_name(future_type)
(self.word_letters, self.word_marks) = ar_verb.uniformate_verb(verb)
#Before last haraka in the past
self.past_haraka = araby.secondlast_char(self.word_marks)
self.word_marks = ar_verb.uniformate_alef_origin(self.word_marks,
self.internal_verb, self.future_type)
self.transitive = transitive
self.hamza_zaida = False
self.tab_conjug_stem = {}
verb = self.verb
tab_type = [u"", u"", u"", u"فعل ثلاثي", u"فعل رباعي", u"فعل خماسي",
u"فعل سداسي", u"فعل سباعي", u"فعل ثماني", u"فعل تساعي"]
verb = ar_verb.normalize(verb)
self.unvocalized = araby.strip_harakat(verb)
verb_nm = self.unvocalized
self.vlength = len(verb_nm)
self.vtype = tab_type[self.vlength]
# الهمزة زائدة
self.hamza_zaida = self._is_hamza_zaida(verb_nm)
# التاء الزائدة
#deprecated
#self.teh_zaida=self.is_teh_zaida(verb_nm)
# معالجة حالة الأفعال الشاذة
# إذا كان الفعل من الشواذ، استخرجنا جذوع التصريف من جدوله
#وإلا ولّدنا جذوع تصريفه
# في المضارع والأمر فقط
# أما الماضي فليس فيه شذوذ
@param resulted_data: the founded resulat from dictionary.
@type resulted_data: list of dict.
@param fully_vocalized_input: if the two words must resect the shadda and vocalized.
@param fully_vocalized_input: Boolean, default is False.
@type word_vocalised: unicode.
@return: list of dictionaries of analyzed words with tags.
@rtype: list.
"""
#~return filter(lambda item: araby.shaddalike(word_vocalised,
#~item.__dict__.get('vocalized', '')), resulted_data)
#~x for x in [1, 1, 2] if x == 1
#~ return [
#~ x for x in resulted_data
#~ if araby.shaddalike(word_vocalised, x.__dict__.get('vocalized', '')) ]
if fully_vocalized_input:
return [x for x in resulted_data if araby.strip_harakat(word_vocalised) ==
araby.strip_harakat(x.__dict__.get('vocalized', ''))]
else:
return [
x for x in resulted_data
if araby.shaddalike(word_vocalised, x.__dict__.get('vocalized', ''))
]
def create_index_triverbtable():
""" Create index from the verb dictionary
to accelerate the search in the dictionary for verbs
@return: create the TRIVERBTABLE_INDEX
@rtype: None
"""
# the key is the vocverb + the bab number
for key in triverbtable.TriVerbTable.keys():
vocverb = triverbtable.TriVerbTable[key]['verb']
unvverb = araby.strip_harakat(vocverb)
normverb = araby.normalize_hamza(unvverb)
if TRIVERBTABLE_INDEX.has_key(normverb):
TRIVERBTABLE_INDEX[normverb].append(key)
else:
TRIVERBTABLE_INDEX[normverb] = [key, ]
@type resulted_data: list of dict.
@param fully_vocalized_input: if the two words must resect the shadda and vocalized.
@param fully_vocalized_input: Boolean, default is False.
@type word_vocalised: unicode.
@return: list of dictionaries of analyzed words with tags.
@rtype: list.
"""
#~return filter(lambda item: araby.shaddalike(word_vocalised,
#~item.__dict__.get('vocalized', '')), resulted_data)
#~x for x in [1, 1, 2] if x == 1
#~ return [
#~ x for x in resulted_data
#~ if araby.shaddalike(word_vocalised, x.__dict__.get('vocalized', '')) ]
if fully_vocalized_input:
return [x for x in resulted_data if araby.strip_harakat(word_vocalised) ==
araby.strip_harakat(x.__dict__.get('vocalized', ''))]
else:
return [
x for x in resulted_data
if araby.shaddalike(word_vocalised, x.__dict__.get('vocalized', ''))
]
self.future_type = ar_verb.get_future_type_by_name(future_type)
(self.word_letters, self.word_marks) = ar_verb.uniformate_verb(verb)
#Before last haraka in the past
self.past_haraka = araby.secondlast_char(self.word_marks)
self.word_marks = ar_verb.uniformate_alef_origin(self.word_marks,
self.internal_verb, self.future_type)
self.transitive = transitive
self.hamza_zaida = False
self.tab_conjug_stem = {}
verb = self.verb
tab_type = [u"", u"", u"", u"فعل ثلاثي", u"فعل رباعي", u"فعل خماسي",
u"فعل سداسي", u"فعل سباعي", u"فعل ثماني", u"فعل تساعي"]
verb = ar_verb.normalize(verb)
self.unvocalized = araby.strip_harakat(verb)
verb_nm = self.unvocalized
self.vlength = len(verb_nm)
self.vtype = tab_type[self.vlength]
# الهمزة زائدة
self.hamza_zaida = self._is_hamza_zaida(verb_nm)
# التاء الزائدة
#deprecated
#self.teh_zaida=self.is_teh_zaida(verb_nm)
# معالجة حالة الأفعال الشاذة
# إذا كان الفعل من الشواذ، استخرجنا جذوع التصريف من جدوله
#وإلا ولّدنا جذوع تصريفه
# في المضارع والأمر فقط
# أما الماضي فليس فيه شذوذ
@type listtense: list of unicode
@return: the result as text in row.
@rtype: unicode.
"""
text = u""
transitive = "0"
if self.transitive:
transitive = '1'
for pronoun in vconst.PronounsTable:
## text += u"%s" % (pronoun)
for tense in listtense:
# print (self.verb).encode("utf-8"),
if self.tab_conjug[tense][pronoun] != "":
text += "\t".join([
araby.strip_harakat(self.tab_conjug[tense][pronoun]),
self.tab_conjug[tense][pronoun],
TAB_DISPLAY[pronoun],
TAB_DISPLAY[tense],
transitive,
self.verb,
self.bab,
])
text += u"\n"
return text
- 'bab':
- 'transitive':
@param triverb: given verb.
@type triverb: unicode.
@param givenharaka: given haraka of tuture type of the verb,
default(FATHA).
@type givenharaka: unicode.
@param VocalisedEntree: True if the given verb is vocalized,
default False.
@type VocalisedEntree: Boolean.
@return: list of triliteral verbs.
@rtype: list of dicts.
"""
liste = []
if vocalised_entree:
verb_nm = araby.strip_harakat(triverb)
else:
verb_nm = triverb
normalized = araby.normalize_hamza(verb_nm)
if TRIVERBTABLE_INDEX.has_key(normalized):
for verb_voc_id in TRIVERBTABLE_INDEX[normalized]:
if triverb == triverbtable.TriVerbTable[verb_voc_id]['verb'] and \
givenharaka == triverbtable.TriVerbTable[verb_voc_id]['haraka']:
liste.insert(0, triverbtable.TriVerbTable[verb_voc_id])
# if VocalisedEntree:
#if verb_voc_id[:-1] == triverb:
# liste.append(TriVerbTable[verb_voc_id])
else:
liste.append(triverbtable.TriVerbTable[verb_voc_id])
else:
print "triverb has no verb"