Пример #1
0
	def __fuzzy_search(self, word):
		""" Выполняет нечеткий поиск слова <word>, в словарях
			отмеченных в конфигурации как <spy>. Выводит результат
			как список, элементами которого являются гипер-ссылки на
			похожие слова.
		"""
		all_lines = []
		used_dicts = self.conf.get_sl_spy_dicts()
		for dic in used_dicts:
			filename = self.conf.get_dic_path(dic)
			lines = libsl.find_word(word, libsl.SL_FIND_FUZZY, filename)
			if lines != []:
				html = []
				html.append(libsl.get_dict_html_block(filename))
				html.append("<dl>")
				for item in lines:
					html.append("<li><a href='%s|%s'>%s</a></li>" % (dic, item, item))
				html.append("</dl>")
				all_lines.append("".join(html))

			# Cancelled..
			if not self.spy_view.get_property("visible"):
				return

		translate = "<body>%s</body>" % ("".join(all_lines))
		gobject.idle_add(self.spy_view.set_translate, word, translate)
Пример #2
0
	def __fuzzy_search(self, word):
		""" Выполняет нечеткий поиск слова <word>, в словарях
			отмеченных в конфигурации как <spy>. Выводит результат
			как список, элементами которого являются гипер-ссылки на
			похожие слова.
		"""
		all_lines = []
		used_dicts = self.conf.get_sl_spy_dicts()
		for dic in used_dicts:
			filename = self.conf.get_dic_path(dic)
			lines = libsl.find_word(word, libsl.SL_FIND_FUZZY, filename)
			if lines != []:
				html = []
				html.append(libsl.get_dict_html_block(filename))
				html.append("<dl>")
				for item in lines:
					html.append("<li><a href='%s|%s'>%s</a></li>" % (dic, item, item))
				html.append("</dl>")
				all_lines.append("".join(html))

			# Cancelled..
			if not self.spy_view.get_property("visible"):
				return

		translate = "<body>%s</body>" % ("".join(all_lines))
		gobject.idle_add(self.spy_view.set_translate, word, translate)
Пример #3
0
    def find_list(self, word, mode=libsl.SL_FIND_LIST):
        if word == "":
            return

        count = 0
        model = self.treestore
        model.clear()

        dictionaries = self.conf.get_used_dicts()
        for dic in dictionaries:

            filename = self.conf.get_dic_path(dic)
            items = libsl.find_word(word, mode, filename)
            count += len(items)
            if items == []:
                continue

            root_node = model.append(None, [dic])
            for item in items:
                model.append(root_node, [item])

        if count > 0:
            self.treeview.expand_all()
            self.word_selection.select_path((0, 0))
        else:
            model.append(None, [_("This word is not found")])

        self.__fire_status_changed(_("Total: %i") % (count))
Пример #4
0
	def find_list(self, word, mode = libsl.SL_FIND_LIST):
		if word == "":
			return

		count = 0
		model = self.treestore
		model.clear()

		dictionaries = self.conf.get_used_dicts()
		for dic in dictionaries:

			filename = self.conf.get_dic_path(dic)
			items = libsl.find_word(word, mode, filename)
			count += len(items)
			if items == []:
				continue
				
			root_node = model.append(None, [dic])
			for item in items:
				model.append(root_node, [item])
				
		if count>0:
			self.treeview.expand_all()
			self.word_selection.select_path((0,0))
		else:
			model.append(None, [_("This word is not found")])

		self.__fire_status_changed(_("Total: %i") % (count))
Пример #5
0
	def __on_url_click(self, document, link):
		dic, word = link.split("|")

		filename = self.conf.get_dic_path(dic)
		lines = libsl.find_word(word, libsl.SL_FIND_MATCH, filename)

		translate = "<body>%s</body>" % ("".join(lines))
		self.spy_view.set_translate(word, translate)
Пример #6
0
	def __on_url_click(self, view, url, type_):
		dic, word = url.split("|")

		filename = self.conf.get_dic_path(dic)
		lines = libsl.find_word(word, libsl.SL_FIND_MATCH, filename)

		translate = "<body>%s</body>" % ("".join(lines))
		self.spy_view.set_translate(word, translate)
Пример #7
0
	def __get_translate(self, word):
		all_lines = []
		used_dicts = self.conf.get_spy_dicts()
		for dic in used_dicts:
			filename = self.conf.get_dic_path(dic)
			lines = libsl.find_word(word, libsl.SL_FIND_MATCH, filename)
			if lines != []:
				all_lines.append("".join(lines))
		return all_lines
Пример #8
0
	def __thread_find(self, node, word, mode, dict_name):

		filename = self.conf.get_dic_path(dict_name)
		items = libsl.find_word(word, mode, filename)

		self.treemodel_lock.acquire()
		if items == []:
			self.treestore.remove(node)
		else:
			for item in items:
				self.treestore.append(node, [item])
		self.treemodel_lock.release()
Пример #9
0
	def __get_translate(self, word):
		""" Возвращает доступные статьи перевода слова <word>, в словарях
		    отмеченных в конфигурации как <spy>. 
		"""
		all_lines = []
		used_dicts = self.conf.get_sl_spy_dicts()
		for dic in used_dicts:
			filename = self.conf.get_dic_path(dic)
			lines = libsl.find_word(word, libsl.SL_FIND_MATCH, filename)
			if lines != []:
				all_lines.append("".join(lines))
		return all_lines
Пример #10
0
	def __get_translate(self, word):
		""" Возвращает доступные статьи перевода слова <word>, в словарях
		    отмеченных в конфигурации как <spy>. 
		"""
		all_lines = []
		used_dicts = self.conf.get_sl_spy_dicts()
		for dic in used_dicts:
			filename = self.conf.get_dic_path(dic)
			lines = libsl.find_word(word, libsl.SL_FIND_MATCH, filename)
			if lines != []:
				all_lines.append("".join(lines))
		return all_lines
Пример #11
0
    def __thread_find(self, node, word, mode, dict_name):

        filename = self.conf.get_dic_path(dict_name)
        items = libsl.find_word(word, mode, filename)

        self.treemodel_lock.acquire()
        if items == []:
            self.treestore.remove(node)
        else:
            for item in items:
                self.treestore.append(node, [item])
        self.treemodel_lock.release()
Пример #12
0
	def find_word(self, treeiter, mode = libsl.SL_FIND_MATCH, newTab=False):
		if treeiter is None:
			return

		parentiter = self.treestore.iter_parent(treeiter)
		if parentiter is None:
			return

		word = self.treestore.get_value(treeiter, 0)
		dic = self.treestore.get_value(parentiter, 0)

		filename = self.conf.get_dic_path(dic)
		lines = libsl.find_word(word, mode, filename)
		translate = "<body>%s</body>" % ("".join(lines))
		self.__fire_translate_changed(word, translate, newTab)
Пример #13
0
    def find_word(self, treeiter, mode=libsl.SL_FIND_MATCH, newTab=False):
        if treeiter is None:
            return

        parentiter = self.treestore.iter_parent(treeiter)
        if parentiter is None:
            return

        word = self.treestore.get_value(treeiter, 0)
        dic = self.treestore.get_value(parentiter, 0)

        filename = self.conf.get_dic_path(dic)
        lines = libsl.find_word(word, mode, filename)
        translate = "<body>%s</body>" % ("".join(lines))
        self.__fire_translate_changed(word, translate, newTab)
Пример #14
0
	def __fuzzy_search(self, word):
		all_lines = []
		used_dicts = self.conf.get_spy_dicts()
		for dic in used_dicts:
			filename = self.conf.get_dic_path(dic)
			lines = libsl.find_word(word, libsl.SL_FIND_FUZZY, filename)
			if lines != []:
				html = []
				html.append(libsl.get_dict_html_block(filename))
				html.append("<dl>")
				for item in lines:
					html.append("<li><a href='%s|%s'>%s</a></li>" % (dic, item, item))
				html.append("</dl>")
				all_lines.append("".join(html))

			# Cancelled..
			if not self.spy_view.get_property("visible"):
				return

		translate = "<body>%s</body>" % ("".join(all_lines))
		gobject.idle_add(self.spy_view.set_translate, word, translate)