(self, index)
| 251 | """A dataset that calls prepare_seq2seq_batch.""" |
| 252 | |
| 253 | def __getitem__(self, index) -> Dict[str, str]: |
| 254 | index = index + 1 # linecache starts at 1 |
| 255 | source_line = self.prefix + linecache.getline(str(self.src_file), index).rstrip("\n") |
| 256 | tgt_line = linecache.getline(str(self.tgt_file), index).rstrip("\n") |
| 257 | assert source_line, f"empty source line for index {index}" |
| 258 | assert tgt_line, f"empty tgt line for index {index}" |
| 259 | return {"tgt_texts": tgt_line, "src_texts": source_line, "id": index - 1} |
| 260 | |
| 261 | def collate_fn(self, batch) -> Dict[str, torch.Tensor]: |
| 262 | """Call prepare_seq2seq_batch.""" |
nothing calls this directly
no outgoing calls
no test coverage detected