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

Method load_json_stream

data_utils/datasets.py:483–498  ·  view source on GitHub ↗
(self, load_path)

Source from the content-addressed store, hash-verified

481 json.dump(jsons, open(save_path, 'w'), separators=(',', ':'))
482
483 def load_json_stream(self, load_path):
484 if not self.loose_json:
485 jsons = json.load(open(load_path, 'r'))
486 generator = iter(jsons)
487 else:
488 def gen_helper():
489 with open(load_path, 'r') as f:
490 for row in f:
491 yield json.loads(row)
492
493 generator = gen_helper()
494
495 for j in generator:
496 if self.label_key not in j:
497 j[self.label_key] = -1
498 yield j
499
500
501class XLDataset(data.Dataset):

Callers 1

__init__Method · 0.95

Calls 1

loadMethod · 0.80

Tested by

no test coverage detected