def mark_on_poem(self, text, cursive=False): self.i_min = None text = daw_araby.fuzzy(text) ls = text.split() ln = len(ls) list_search = [] text_page0 = self.view_abiat_bfr.get_text(self.view_abiat_bfr.get_start_iter(), self.view_abiat_bfr.get_end_iter(), False).decode('utf8') self.text_page = daw_araby.stripTatweel(text_page0) ls_poem, nw = daw_tools.n_words(self.text_page) list_word = text_page0.split() if cursive == False: for n in range(nw): for k in range(len(ls)): if ls[k] in daw_araby.fuzzy(ls_poem[n]) or ls[k] in ls_poem[n]: list_search.append(daw_customs.tashkil(list_word[n])) else: for n in range(nw): ntext = daw_araby.fuzzy(' '.join(ls_poem[n:n+ln])) if text in ntext: list_search.append(daw_customs.tashkil(' '.join(list_word[n:n+ln]))) for txt in list_search: cursor_mark = self.view_abiat_bfr.get_insert() start = self.view_abiat_bfr.get_iter_at_mark(cursor_mark) if start.get_offset() == self.view_abiat_bfr.get_char_count(): start = self.view_abiat_bfr.get_start_iter() self.search_and_mark2(txt, start)
def first_term(text): text = re.sub('\n', ' ', text) text = re.sub(' +', ' ', text) text = text.strip() ls = text.split(' ') txt = daw_araby.stripTatweel(ls[0]) return txt
def explain_term(self, *a): if self.view_poem_bfr.get_has_selection(): sel = self.view_poem_bfr.get_selection_bounds() sel_text = self.view_poem_bfr.get_text(sel[0], sel[1],True) text = daw_araby.stripTatweel(sel_text.decode('utf8')) text = daw_tools.first_term(text) if len(text) >= 3: all_root, all_term = daw_stemming.get_root(u''+text) if len(all_root['taje'])+len(all_root['assas'])+len(all_root['lisan'])+len(all_root['mekhtar']) == 0: daw_customs.erro(self.parent, 'لا يوجد نتيجة'); return self.parent.dictpage.tree_dict.collapse_all() self.parent.dictpage.store_dict.clear() self.parent.dictpage.view_dict_bfr.set_text('') if len(all_root['taje'])+len(all_root['assas'])+len(all_root['lisan'])+len(all_root['mekhtar']) == 0: daw_customs.erro(self.parent, 'لا يوجد نتيجة'); return if len(all_root['lisan']) != 0: a1 = self.parent.dictpage.store_dict.append(None, ['لسان العرب', 'lisan']) for text in all_root['lisan']: self.parent.dictpage.store_dict.append(a1, [text, 'lisan']) if len(all_root['taje']) != 0: a2 = self.parent.dictpage.store_dict.append(None, ['تاج العروس', 'taje']) for text in all_root['taje']: self.parent.dictpage.store_dict.append(a2, [text, 'taje']) if len(all_root['assas']) != 0: a3 = self.parent.dictpage.store_dict.append(None, ['أساس البلاغة', 'assas']) for text in all_root['assas']: self.parent.dictpage.store_dict.append(a3, [text, 'assas']) if len(all_root['mekhtar']) != 0: a4 = self.parent.dictpage.store_dict.append(None, ['مختار الصحاح', 'mekhtar']) for text in all_root['mekhtar']: self.parent.dictpage.store_dict.append(a4, [text, 'mekhtar']) self.parent.dictpage.all_term = all_term self.parent.main_notebook.set_current_page(7) self.parent.dicty_page.set_active(True)
def scan_verse(text, v=0): text = re.sub(' +', ' ', text) #text = re.sub('_', '', text) text = daw_araby.stripTatweel(text) text = shadda_end(text) text = not_rw(text) text = daw_araby.take_apart_tense(text) if v == 0: text = ishbaa_ha(text) text = ishbaa_mim(text) #text = tashkil_plus(text) text = tanwin(text) text = itlak(text) ls = syllable(text) txt = u''+ls[0][0][0] wazn = '1' for a in range(len(ls)): for c in range(len(ls[a])): if a == 0 and c == 0: continue if a < len(ls)-1: if c < len(ls[a])-1: if ls[a][c][1] == 0 and ls[a][c+1][1] == 0: continue else: txt += ls[a][c][0] wazn += str(ls[a][c][1]) else: if ls[a][c][1] == 0 and ls[a+1][0][1] == 0: continue else: txt += ls[a][c][0] wazn += str(ls[a][c][1]) else: if c < len(ls[a])-2: if ls[a][c][1] == 0 and ls[a][c+1][1] == 0: continue else: txt += ls[a][c][0] wazn += str(ls[a][c][1]) else: txt += ls[a][c][0] wazn += str(ls[a][c][1]) txt += u' ' if wazn[-1] == '1': wazn += '0' takti3 = re.sub('1',u'/', wazn) return txt, takti3, wazn
def one_half(text): ls = text.split(' ') txt = daw_araby.stripTatweel(ls[0]) return txt