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 visible_cb(self, model, itr, data): if len(self.theword) == 0: return if daw_araby.fuzzy(self.theword[0][0]) in daw_araby.fuzzy(model.get_value(itr, 1).decode('utf8')) and\ (self.theword[0][1] == model.get_value(itr, 2) or self.theword[0][1] == 0) and\ (self.theword[0][2] == model.get_value(itr, 3) or self.theword[0][2] == 0) and\ (self.theword[0][3] == model.get_value(itr, 4) or self.theword[0][3] == 0): return True else: return False
def search_on_page(self, text): self.show_page_help() search_tokens = [] nasse = self.prescript_bfr.get_text(self.prescript_bfr.get_start_iter(), self.prescript_bfr.get_end_iter(),True).split() if text != u'': txt = daw_araby.fuzzy(text) for term in nasse: if txt in daw_araby.fuzzy(term.decode('utf8')): search_tokens.append(term) daw_customs.with_tag(self.prescript_bfr, self.search_tag, search_tokens)
def search_half(self, text): self.i_min = None text = text.decode('utf8') list_search = [] self.build(self.new_font) ls_poem = self.new_poem.splitlines(1) for a in ls_poem: if daw_araby.fuzzy(text) in daw_araby.fuzzy(a) : list_search.append(daw_customs.tashkil(a)) for txt in list_search: cursor_mark = self.view_poem_bfr.get_insert() start = self.view_poem_bfr.get_iter_at_mark(cursor_mark) if start.get_offset() == self.view_poem_bfr.get_char_count(): start = self.view_poem_bfr.get_start_iter() self.search_and_mark(txt, start)
def is_poem_exists(self, name, sex, balad, age, abiat, baher, rawi, kafia, arodh, gharadh, naw3, longer_half): self.cur.execute('SELECT id_poem FROM infopoem WHERE fuzzy(name)=? AND sex=? AND balad=? AND \ age=? AND abiat=? AND id_baher=? AND rawi=? AND kafia=? AND arodh=? AND gharadh=? AND naw3=? AND length=?', (daw_araby.fuzzy(name), sex, balad, age, abiat, baher, rawi, kafia, arodh, gharadh, naw3, longer_half)) poems = self.cur.fetchall() return poems
def add_poem_from_fileDB(self, id_poem, filename, v=False): con = sqlite3.connect(filename) cur = con.cursor() cur.execute('SELECT * FROM infopoem WHERE id_poem=?', (id_poem,) ) poem_info = cur.fetchall() cur.execute('SELECT * FROM kassaid WHERE id_poem=?', (id_poem,) ) poem_text = cur.fetchall() poet = poem_info[0][2] cur.execute('SELECT * FROM poets WHERE id_poet=?', (poet,) ) poet_info = cur.fetchall() sex = poem_info[0][3] balad = poem_info[0][4] age = poem_info[0][5] nam = poem_info[0][1] text = poem_text[0][1] sabab = poem_text[0][2] charh = poem_text[0][3] abiat = poem_info[0][6] baher = poem_info[0][7] rawi = poem_info[0][8] kafia = poem_info[0][9] arodh = poem_info[0][10] gharadh = poem_info[0][11] naw3 = poem_info[0][12] longer_half = poem_info[0][14] if len(poet_info) == 0: id_poet = 0 else: name_poet = poet_info[0][1] lakab_poet = poet_info[0][2] tardjama = poet_info[0][3] death = poet_info[0][4] poet0 = self.is_poet_exists(daw_araby.fuzzy(lakab_poet), age, balad) if len(poet0) == 0: id_poet, sex, balad, age = self.add_poet(name_poet, lakab_poet, tardjama, death, sex, balad, age) else: id_poet = poet0[0][0] poem = self.is_poem_exists(daw_araby.fuzzy(nam), sex, balad, age, abiat, baher, rawi, kafia, arodh, gharadh, naw3, longer_half) if len(poem) > 0: if v: id_poem = poem[0][0] self.modify_poem(id_poem, nam, text, sabab, charh, id_poet, sex, balad, age, abiat, baher, rawi, kafia, arodh, gharadh, naw3, longer_half) return True self.add_poem(nam, text, sabab, charh, id_poet, sex, balad, age, abiat, baher, rawi, kafia, arodh, gharadh, naw3, longer_half) return True
def search_on_page(self, text): self.show_charh() while (Gtk.events_pending()): Gtk.main_iteration() search_tokens = [] nasse = self.view_dict_bfr.get_text(self.view_dict_bfr.get_start_iter(), self.view_dict_bfr.get_end_iter(),True).split() if text == u'': for a in self.all_term: txt = daw_araby.fuzzy(a) for term in nasse: if txt in daw_araby.fuzzy(term.decode('utf8')): search_tokens.append(term) else: txt = daw_araby.fuzzy(text) for term in nasse: if txt in daw_araby.fuzzy(term.decode('utf8')): search_tokens.append(term) daw_customs.with_tag(self.view_dict_bfr, self.search_tag, search_tokens)
def visible_cb0(self, model, itr, data): if len(self.theword) == 0: return if daw_araby.fuzzy(self.theword0[0]) in daw_araby.fuzzy(model.get_value(itr, 1).decode('utf8')): return True else: return False
def is_poet_exists(self, lakab_poet, age, balad): self.cur.execute('SELECT id_poet FROM poets WHERE fuzzy(lakab)=? AND balad=? AND age=?', (daw_araby.fuzzy(lakab_poet), balad, age)) poet = self.cur.fetchall() return poet