MCPcopy Create free account
hub / github.com/THUDM/GLM / _create_examples

Method _create_examples

tasks/superglue/dataset.py:1370–1394  ·  view source on GitHub ↗
(self, path: str, set_type: str, cloze_eval=True)

Source from the content-addressed store, hash-verified

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
1397class CMRCProcessor(DataProcessor):

Callers 3

get_train_examplesMethod · 0.95
get_dev_examplesMethod · 0.95
get_test_examplesMethod · 0.95

Calls 2

InputExampleClass · 0.90
appendMethod · 0.80

Tested by

no test coverage detected