(self, path: str, set_type: str, cloze_eval=True)
| 1368 | return ["false", "true"] |
| 1369 | |
| 1370 | def _create_examples(self, path: str, set_type: str, cloze_eval=True) -> List[InputExample]: |
| 1371 | examples = [] |
| 1372 | |
| 1373 | with open(path, encoding='utf8') as f: |
| 1374 | for line in f: |
| 1375 | example_json = json.loads(line) |
| 1376 | idx = example_json['id'] if 'id' in example_json else example_json['idx'] |
| 1377 | label = example_json['label'] if 'label' in example_json else None |
| 1378 | guid = "%s-%s" % (set_type, idx) |
| 1379 | text_a = example_json['text'] |
| 1380 | |
| 1381 | meta = { |
| 1382 | 'span1_text': example_json['target']['span1_text'], |
| 1383 | 'span2_text': example_json['target']['span2_text'], |
| 1384 | 'span1_index': example_json['target']['span1_index'], |
| 1385 | 'span2_index': example_json['target']['span2_index'], |
| 1386 | } |
| 1387 | meta['span1_length'] = len(meta['span1_text']) |
| 1388 | meta['span2_length'] = len(meta['span2_text']) |
| 1389 | |
| 1390 | example = InputExample( |
| 1391 | guid=guid, text_a=text_a, text_b=meta['span1_index'], label=label, meta=meta, idx=idx) |
| 1392 | examples.append(example) |
| 1393 | |
| 1394 | return examples |
| 1395 | |
| 1396 | |
| 1397 | class CMRCProcessor(DataProcessor): |
no test coverage detected