MCPcopy Create free account
hub / github.com/RingBDStack/GDAP / __getitem__

Method __getitem__

seq2seq/utils.py:253–259  ·  view source on GitHub ↗
(self, index)

Source from the content-addressed store, hash-verified

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."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected