def conclude_report(self) -> None: if self.hyp_sents: ref_filename = os.path.join(self.report_path, "tmp", "compare-mt.ref") out_filename = os.path.join(self.report_path, "tmp", "compare-mt.out") utils.make_parent_dir(out_filename) with open(ref_filename, "w") as fout: for l in self.ref_sents: fout.write(f"{l.strip()}\n") with open(out_filename, "w") as fout: for l in self.hyp_sents: fout.write(f"{l.strip()}\n") import xnmt.thirdparty.comparemt.compare_mt as compare_mt args = utils.ArgClass(ref_file=ref_filename, out_file=out_filename, out2_file=self.out2_file, train_file=self.train_file, train_counts=self.train_counts, alpha=self.alpha, ngram=self.ngram, ngram_size=self.ngram_size, sent_size=self.sent_size) out_lines = compare_mt.main(args) report_filename = os.path.join(self.report_path, "compare-mt.txt") utils.make_parent_dir(report_filename) with open(report_filename, "w") as fout: for l in out_lines: fout.write(f"{l}\n") self.hyp_sents, self.ref_sents, self.src_sents = [], [], []
def conclude_report(self) -> None: if self.hyp_sents: html_filename = os.path.join(self.report_path, "charcut.html") utils.make_parent_dir(html_filename) args = utils.ArgClass(html_output_file=html_filename, match_size=self.match_size, alt_norm=self.alt_norm) aligned_segs = charcut.load_input_segs(cand_segs=self.hyp_sents, ref_segs=self.ref_sents, src_segs=self.src_sents) charcut.run_on(aligned_segs, args) self.hyp_sents, self.ref_sents, self.src_sents = [], [], []