File size: 1,058 Bytes
319e81d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import glob
import json
import os
from pathlib import Path
import mteb
def resize_flores():
"""
includes only relevant splits from the FloresBitextMining.json files
"""
paths = Path(__file__).parent.glob("**/FloresBitextMining.json")
for p in paths:
try:
res = mteb.MTEBResults.from_disk(p)
res.validate_and_filter_scores()
res.to_disk(p)
except Exception:
pass
def remove_spaces():
"""
removes spaces from the json files
"""
for file in glob.glob("results/*/*/*.json"):
# if the file is greater than 9 MB, compress it with gzip
if os.path.getsize(file) >= 9.5 * 1024 * 1024:
print(f"Resizing {file} to have no indentations")
# read it in as json and write it out with no indent
with open(file, "r") as f:
data = json.load(f)
with open(file, "w") as f:
json.dump(data, f, indent=None)
if __name__ == "__main__":
resize_flores()
remove_spaces()
|