def clear_concordance_view(self): misc.enable_all_in_frame(self.conc_results_frame) self.conc_line_text.delete("0.0", "end") self.conc_index_text.delete("0.0", "end") for key, m_text in self.conc_meta_text.items(): m_text.delete("0.0", "end") misc.disable_all_in_frame(self.conc_results_frame)
def clear_concordance_view(self): misc.enable_all_in_frame(self.results_frame) self.line_text.delete("0.0", "end") self.index_text.delete("0.0", "end") for key, m_text in self.meta_text.items(): m_text.delete("0.0", "end") misc.disable_all_in_frame(self.results_frame)
def display_concordance(self): if self.concordance is not None: misc.enable_all_in_frame(self.results_frame) for i, l in enumerate(self.concordance): self.add_concordance_line(l, i) self.parent.root.update_idletasks() if len(self.concordance) > 0: self.improve_concordance_display() misc.disable_all_in_frame(self.results_frame)
def create_concordance(self): self.clear_concordance_view() self.concordance = [] self.concordance_filtered = [] if self.start_button["text"] == "Search all corpora": self.cancelled = False self.export_button["state"] = "disabled" self.filter_button["state"] = "disabled" self.parent.set_status("Creating concordance ...") self.start_button["text"] = "Abort" self.index_text["width"] = 6 options = misc.get_tk_vars(self.parent.settings_frame.definition) options.update(misc.get_tk_vars(self.parent.settings_frame.file)) options.update( misc.get_tk_vars(self.parent.settings_frame.concordance)) options.update(misc.get_tk_vars(self.parent.settings_frame.xml)) options[ "SearchTerm"] = self.parent.concordance_frame.search_var.get() self.options = options self.add_search_term(options["SearchTerm"]) self.pipes = [] self.jobs = [] self.corpora = [] self.shared = [] misc.enable_all_in_frame(self.results_frame) self.q = mp.Queue() for i, corpus in enumerate(self.parent.corpus): corpus_tag = "C{}".format(corpus.name_var.get().replace( " ", "")) self.meta_text["Corpus"].tag_configure(corpus_tag, background=corpus.color) misc.enable_all_in_frame(corpus.conc_results_frame) misc.disable_all_in_frame(corpus.conc_button_frame) options["CorpusIndex"] = i options["Corpus"] = corpus.name_var.get() corpus.conc_options = options manager = mp.Manager() corpus.conc_return_shared = manager.list() job = mp.Process(target=worker_search_files, args=( corpus.files, options, corpus.conc_return_shared, self.q, )) self.jobs.append(job) job.start() self.parent.root.update_idletasks() self.parent.root.after(500, self.check_proc_statuses) elif self.start_button["text"] == "Abort": self.cancelled = True self.parent.set_status("Concordance creation was aborted.", True) self.start_button.configure(text="Search", state="normal") self.parent.root.update_idletasks() for job in self.jobs: job.terminate()
def create_concordance(self): self.clear_concordance_view() self.concordance = [] self.concordance_filtered = [] if self.start_button["text"] == "Search all corpora": self.cancelled = False self.export_button["state"] = "disabled" self.filter_button["state"] = "disabled" self.parent.set_status("Creating concordance ...") self.start_button["text"] = "Abort" self.index_text["width"] = 6 options = misc.get_tk_vars(self.parent.settings_frame.definition) options.update(misc.get_tk_vars(self.parent.settings_frame.file)) options.update(misc.get_tk_vars(self.parent.settings_frame.concordance)) options.update(misc.get_tk_vars(self.parent.settings_frame.xml)) options["SearchTerm"] = self.parent.concordance_frame.search_var.get() self.options = options self.add_search_term(options["SearchTerm"]) self.pipes = [] self.jobs = [] self.corpora = [] self.shared = [] misc.enable_all_in_frame(self.results_frame) self.q = mp.Queue() for i, corpus in enumerate(self.parent.corpus): corpus_tag = "C{}".format(corpus.name_var.get().replace(" ", "")) self.meta_text["Corpus"].tag_configure(corpus_tag, background=corpus.color) misc.enable_all_in_frame(corpus.conc_results_frame) misc.disable_all_in_frame(corpus.conc_button_frame) options["CorpusIndex"] = i options["Corpus"] = corpus.name_var.get() corpus.conc_options = options manager = mp.Manager() corpus.conc_return_shared = manager.list() job = mp.Process(target=worker_search_files, args=(corpus.files, options, corpus.conc_return_shared, self.q,)) self.jobs.append(job) job.start() self.parent.root.update_idletasks() self.parent.root.after(500, self.check_proc_statuses) elif self.start_button["text"] == "Abort": self.cancelled = True self.parent.set_status("Concordance creation was aborted.", True) self.start_button.configure(text="Search", state="normal") self.parent.root.update_idletasks() for job in self.jobs: job.terminate()
def filter_concordance(self): if len(self.concordance) > 0: self.concordance_filtered = [] filter_by = self.filter_var.get() what = self.filter_what_combo.get() case = bool(self.parent.settings_frame.concordance['Case'].get()) regex = bool( self.parent.settings_frame.concordance['IsRegEx'].get()) if case and not regex: filter_by = filter_by.lower() elif regex: if case: flags = re.UNICODE else: flags = re.UNICODE | re.IGNORECASE s = r'{0}'.format(filter_by) re_pattern = re.compile(s, flags=flags) for l in self.concordance: if what == "Line": line = "{} {} {}".format(l['Left'], l['Key'], l['Right']) if not regex: if not case: line = line.lower() if filter_by in line: self.concordance_filtered.append(l) else: if re_pattern.search(line): self.concordance_filtered.append(l) else: if not regex: if not case: l[what] = l[what].lower() if filter_by in l[what]: self.concordance_filtered.append(l) else: if re_pattern.search(l[what]): self.concordance_filtered.append(l) self.clear_concordance_view() misc.enable_all_in_frame(self.results_frame) for i, l in enumerate(self.concordance_filtered): self.add_concordance_line(l, i) self.parent.root.update_idletasks() misc.disable_all_in_frame(self.results_frame) self.unfilter_button["state"] = "enabled"
def filter_concordance(self): if len(self.concordance) > 0: self.concordance_filtered = [] filter_by = self.conc_filter_var.get() what = self.conc_filter_what_combo.get() case = bool(self.parent.settings_frame.concordance['Case'].get()) regex = bool(self.parent.settings_frame.concordance['IsRegEx'].get()) if case and not regex: filter_by = filter_by.lower() elif regex: if case: flags = re.UNICODE else: flags = re.UNICODE | re.IGNORECASE s = r'{0}'.format(filter_by) re_pattern = re.compile(s, flags=flags) for l in self.concordance: if what == "Line": line = "{} {} {}".format(l['Left'], l['Key'], l['Right']) if not regex: if not case: line = line.lower() if filter_by in line: self.concordance_filtered.append(l) else: if re_pattern.search(line): self.concordance_filtered.append(l) else: if not regex: if not case: l[what] = l[what].lower() if filter_by in l[what]: self.concordance_filtered.append(l) else: if re_pattern.search(l[what]): self.concordance_filtered.append(l) self.clear_concordance_view() misc.enable_all_in_frame(self.conc_results_frame) for i, l in enumerate(self.concordance_filtered): self.add_concordance_line(l, i) self.parent.root.update_idletasks() misc.disable_all_in_frame(self.conc_results_frame) self.conc_unfilter_button["state"] = "enabled"