def main(args: argparse.Namespace) -> None: # Word-level measures. correct = 0 incorrect = 0 # Label-level measures. total_edits = 0 total_length = 0 # Aux measures ignorance_edits = 0. dominance_edits = 0. no_feature_edits = 0. ped_edits = 0. # Since the edit distance algorithm is quadratic, let's do this with # multiprocessing. with multiprocessing.Pool(args.cores) as pool: gen = pool.starmap(evallib.score, evallib.tsv_reader(args.tsv_path)) for (edits, length, (ig, dom, nof, ped)) in gen: if edits == 0: correct += 1 else: incorrect += 1 total_edits += edits total_length += length ignorance_edits += ig dominance_edits += dom no_feature_edits += nof ped_edits += ped print(f"WER:\t{100 * incorrect / (correct + incorrect):.2f}") print(f"LER:\t{100 * total_edits / total_length:.2f}") print(f"PED_IG:\t{100 * ignorance_edits / total_length:.2f}") print(f"PED_DOM:\t{100 * dominance_edits / total_length:.2f}") print(f"PED_NOF:\t{100 * no_feature_edits / total_length:.2f}") print(f"PED:\t{100 * ped_edits / total_length:.2f}")
def main(args: argparse.Namespace) -> None: wers = [] lers = [] for tsv_path in args.tsv_paths: # Word-level measures. correct = 0 incorrect = 0 # Label-level measures. total_edits = 0 total_length = 0 # Since the edit distance algorithm is quadratic, let's do this with # multiprocessing. with multiprocessing.Pool(args.cores) as pool: gen = pool.starmap(evallib.score, evallib.tsv_reader(tsv_path)) for (edits, length) in gen: if edits == 0: correct += 1 else: incorrect += 1 total_edits += edits total_length += length wer = 100 * incorrect / (correct + incorrect) ler = 100 * total_edits / total_length wers.append(wer) lers.append(ler) print(f"{tsv_path}:\tWER:\t{wer:.2f}\tLER:\t{ler:.2f}") wer = statistics.mean(wers) ler = statistics.mean(lers) print(f"Macro-average:\tWER:\t{wer:.2f}\tLER:\t{ler:.2f}")
def main(args: argparse.Namespace) -> None: correct = 0 incorrect = 0 for (gold, hypo) in evallib.tsv_reader(args.tsv_path): if gold == hypo: correct += 1 else: incorrect += 1 wer = evallib.wer(correct, incorrect) print(f"WER:\t{wer:5.2f}")
def main(args: argparse.Namespace) -> None: wers = [] for tsv_path in args.tsv_paths: correct = 0 incorrect = 0 for (gold, hypo) in evallib.tsv_reader(tsv_path): if gold == hypo: correct += 1 else: incorrect += 1 wer = evallib.wer(correct, incorrect) wers.append(wer) print(f"{tsv_path} WER:\t{wer:5.2f}") wer = statistics.mean(wers) print(f"Macro-average WER:\t{wer:5.2f}")
def main(args: argparse.Namespace) -> None: # Word-level measures. correct = 0 incorrect = 0 # Label-level measures. total_edits = 0 total_length = 0 # Since the edit distance algorithm is quadratic, let's do this with # multiprocessing. with multiprocessing.Pool(args.cores) as pool: gen = pool.starmap(evallib.score, evallib.tsv_reader(args.tsv_path)) for (edits, length) in gen: if edits == 0: correct += 1 else: incorrect += 1 total_edits += edits total_length += length print(f"WER:\t{100 * incorrect / (correct + incorrect):.2f}") print(f"LER:\t{100 * total_edits / total_length:.2f}")