def receive_pronunciation(data, nexus): '''get pronunciation''' pronunciation=data[0].split("\n")[0] if pronunciation=="" or pronunciation.isspace(): return '''get other symbols in file''' directory_index = int(data[1][1]) file_index = int(data[1][2]) chosen_directory = scanner.DATA["directories"].keys()[directory_index] chosen_file = scanner.DATA["directories"][chosen_directory].keys()[file_index] names = scanner.DATA["directories"][chosen_directory][chosen_file]["names"] '''get symbol''' symbol = data[1][0].split(settings.HMC_SEPARATOR)[-1] '''get algorithm guesses for file''' ten_guesses = get_similar_symbol_name(pronunciation, names) '''write to file''' entry = [pronunciation, symbol]+[x for x in ten_guesses if x!=symbol] log_file_path = settings.SETTINGS["paths"]["PITA_LOG_FOLDER"] + "/pita_matches.log" with open(log_file_path, "a") as log_file: log_file.write(str(entry) + "\n") '''relaunch''' trainer_box(nexus)
def pita(textnv): global OLD_ACTIVE_WINDOW_TITLE, ACTIVE_FILE_PATH filename, folders, title = utilities.get_window_title_info() active_has_changed = OLD_ACTIVE_WINDOW_TITLE != title # check to see if the active file has changed; if not, skip this step if active_has_changed: OLD_ACTIVE_WINDOW_TITLE = title ACTIVE_FILE_PATH = scanner.guess_file_based_on_window_title(filename, folders) if filename == None: utilities.report("pita: filename pattern not found in window title") return if ACTIVE_FILE_PATH[0] != None: global CHOICES CHOICES = selector.get_similar_symbol_name(str(textnv), scanner.DATA["directories"][ACTIVE_FILE_PATH[0]][ACTIVE_FILE_PATH[1]]["names"]) try: if settings.SETTINGS["miscellaneous"]["status_window_enabled"]: display = "" counter = 1 for result in CHOICES: if counter>1: display+="\n" display+=str(counter)+" "+result[1] counter+=1 control.nexus().intermediary.hint(display) except Exception: utilities.simple_log()
def pita(textnv): global OLD_ACTIVE_WINDOW_TITLE, ACTIVE_FILE_PATH filename, folders, title = utilities.get_window_title_info() active_has_changed = OLD_ACTIVE_WINDOW_TITLE != title # check to see if the active file has changed; if not, skip this step if active_has_changed: OLD_ACTIVE_WINDOW_TITLE = title ACTIVE_FILE_PATH = scanner.guess_file_based_on_window_title(filename, folders) if filename == None: utilities.report("pita: filename pattern not found in window title") return if ACTIVE_FILE_PATH[0] != None: result = selector.get_similar_symbol_name(str(textnv), scanner.DATA["directories"][ACTIVE_FILE_PATH[0]][ACTIVE_FILE_PATH[1]]["names"]) # print "fuzzy match: ", str(textnv), "->", result Text(result)._execute()
def pita_filter(data, choices): return selector.get_similar_symbol_name(list(data["text"].words), choices)