def create_sent_report(self, src: sent.Sentence, output: sent.ReadableSentence, attentions: np.ndarray, ref_file: Optional[str], **kwargs) -> None: """ Create report. Args: src: source-side input output: generated output attentions: attention matrices ref_file: path to reference file **kwargs: arguments to be ignored """ self.cur_sent_no += 1 if self.max_num_sents and self.cur_sent_no > self.max_num_sents: return reference = utils.cached_file_lines(ref_file)[output.idx] idx = src.idx self.add_sent_heading(idx) src_tokens = src.str_tokens() if isinstance( src, sent.ReadableSentence) else [] trg_tokens = output.str_tokens() src_str = src.sent_str() if isinstance(src, sent.ReadableSentence) else "" trg_str = output.sent_str() self.add_charcut_diff(trg_str, reference) self.add_fields_if_set({"Src": src_str}) self.add_atts( attentions, src.get_array() if isinstance(src, sent.ArraySentence) else src_tokens, trg_tokens, idx) self.finish_sent()
def create_sent_report(self, output: sent.ReadableSentence, ref_file: str, **kwargs) -> None: """ Create report. Args: output: generated output ref_file: path to reference file **kwargs: arguments to be ignored """ reference = utils.cached_file_lines(ref_file)[output.idx] trg_str = output.sent_str() self.hyp_sents.append(trg_str) self.ref_sents.append(reference)
def create_sent_report(self, src: sent.Sentence, output: sent.ReadableSentence, ref_file: Optional[str] = None, **kwargs) -> None: """ Create report. Args: src: source-side input output: generated output ref_file: path to reference file **kwargs: arguments to be ignored """ reference = utils.cached_file_lines(ref_file)[output.idx] trg_str = output.sent_str() if isinstance(src, sent.ReadableSentence): src_str = src.sent_str() self.src_sents.append(src_str) self.hyp_sents.append(trg_str) self.ref_sents.append(reference)
def create_sent_report(self, output: sent.ReadableSentence, ref_file: str, **kwargs) -> None: self.output_vocab = output.vocab reference = utils.cached_file_lines(ref_file)[output.idx] self.ref_lines.append(reference) self.out_sents.append(output)