Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fields['wordtype'] = araby.strip_tashkeel(fields['category'])+u":%s"%self.wordtype;
# extarct broken plurals
# extract plural from the plural field
# the field can have +ون;+ات
items = fields['plural'].split(";")
if u'+ون' in items:items.remove(u'+ون')
if u'+ات' in items:items.remove(u'+ات')
if u'ون' in items:items.remove(u'ون')
if u'ات' in items:items.remove(u'ات')
if items:
fields['broken_plural'] = u";".join(items);
else:
fields['broken_plural'] = "";
#display order
fields['normalized'] = araby.normalize_hamza(fields['unvocalized'])
fields['stamped'] = ndf.word_stamp(fields['unvocalized'])
# special change in some fields
# some fields are not fully defined,
# if the k_prefix si Null, it means True,
# if is N or n, it's False
if fields['k_prefix'] in ('n', 'N'):
fields['k_prefix'] = 0
else:
fields['k_prefix'] = 1
# if the kal_prefix si Null, it means True,
# if is N or n, it's False
if fields['kal_prefix'] in ('n', 'N'):
fields['kal_prefix'] = 0
else:
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, ]
def treat_tuple(self,tuple_verb):
""" convert row data to specific fields
return a dict of fields"""
#~ self.id+=1;
v = {} # verb dict of fields
# word tri root future_type transitive nb_trans object_type reflexive_type tenses model nb_case verb_cat suggest
v["word"] = tuple_verb[0].strip();
v["unvocalized"] = araby.strip_tashkeel(v['word']);
v["tri"] = tuple_verb[1].strip();
v['root'] = tuple_verb[2].strip();
v['normalized'] = araby.normalize_hamza(v['unvocalized'])
v['stamp'] = vdf.stamp(v['unvocalized'])
v['future_type']= tuple_verb[3].strip();
v['transitive'] = tuple_verb[4].strip();
v['nb_trans'] = tuple_verb[5].strip();
v['object_type']= tuple_verb[6].strip();
v['reflexive_type'] = tuple_verb[7].strip();
v['tenses'] = tuple_verb[8].strip();
#v['#model'] = tuple_verb[9].strip();
v['nb_case'] = tuple_verb[10].strip();
#v['#verb_cat'] = tuple_verb[11].strip();
#v['#suggest'] = tuple_verb[12].strip();
# Adopt fields to the actual program
#word;
if v['tri'] == u"ثلاثي":
v['triliteral'] = True;
@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"
return liste
def main():