gen_all_data.py 580 B

1234567891011121314151617
  1. """
  2. These codes are adopted from LEAF with some modifications.
  3. """
  4. import json
  5. import os
  6. from easyfl.datasets.shakespeare.utils.shake_utils import parse_data_in
  7. def generated_all_data(parent_path):
  8. users_and_plays_path = os.path.join(parent_path, 'raw_data', 'users_and_plays.json')
  9. txt_dir = os.path.join(parent_path, 'raw_data', 'by_play_and_character')
  10. json_data = parse_data_in(txt_dir, users_and_plays_path)
  11. json_path = os.path.join(parent_path, 'all_data', 'all_data.json')
  12. with open(json_path, 'w') as outfile:
  13. json.dump(json_data, outfile)