Datasets:
mteb
/

Modalities:
Text
Formats:
json
Libraries:
Datasets
pandas
KennethEnevoldsen commited on
Commit
237a43a
•
1 Parent(s): f1b4261

reformatted data to jsonl.gz due to utf decode error

Browse files
data/{test-00000-of-00001.parquet → test.jsonl.gz} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ab49a51e8b4cdbf790ca6b55943a542ad2b5f7bb32bd2119ea02d8f895a89882
3
- size 11809633
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:095362409a8a4e06819ad18d4b59d03604716e9d4e3ac1070cc3019e5146e576
3
+ size 7528112
data/{train-00000-of-00001.parquet → train.jsonl.gz} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c0a67ba42c4cca9f1243e3d2b1250a07c146d1c621b805f684e320d616cfe12e
3
- size 14342268
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fe4f87ffad31bf6caf3da56a6b671bbc1150e53b839a6e0f9580347334e2488f
3
+ size 9018863
remove_empty/remove_empty.log CHANGED
The diff for this file is too large to render. See raw diff
 
remove_empty/remove_empty.py CHANGED
@@ -9,9 +9,10 @@ if log_file_path.exists():
9
  log_file_path.unlink()
10
 
11
  tasks = mteb.get_tasks(tasks=["STS22"])
12
- task = tasks[0]
13
 
14
- task.load_data()
 
 
15
 
16
 
17
  def filter_sample(x):
@@ -24,31 +25,26 @@ def filter_sample(x):
24
  return False
25
 
26
 
27
- for hf_subset in task.dataset:
28
- _ds = task.dataset[hf_subset]
29
- for split in _ds:
30
- ds = _ds[split]
31
- # filter empty sentences
32
- n_samples = len(ds)
33
- ds = ds.filter(lambda x: filter_sample(x))
34
- n_left = len(ds)
35
- log = f"Filtered {n_samples - n_left} samples from {n_samples} in {hf_subset} - {split}"
36
- with open(log_file_path, "a") as f:
37
- f.write(log + "\n")
38
- print(log)
39
- _ds[split] = ds
40
-
41
- task.dataset[hf_subset] = _ds
42
-
43
- save_path = Path(__file__).parent.parent
44
-
45
- for hf_subset in task.dataset:
46
- _ds = task.dataset[hf_subset]
47
- for split in _ds:
48
- ds = _ds[split]
49
- ds.to_json(save_path / split / (hf_subset + ".jsonl.gz"), compression="gzip")
50
- log = f"Saved {hf_subset} - {split} to {save_path / split / (hf_subset + '.jsonl.gz')}"
51
-
52
- with open(log_file_path, "a") as f:
53
- f.write(log + "\n")
54
- print(log)
 
9
  log_file_path.unlink()
10
 
11
  tasks = mteb.get_tasks(tasks=["STS22"])
 
12
 
13
+ from datasets import load_dataset
14
+
15
+ dataset = load_dataset(**tasks[0].metadata.dataset)
16
 
17
 
18
  def filter_sample(x):
 
25
  return False
26
 
27
 
28
+ for split in dataset:
29
+ ds = dataset[split]
30
+ # filter empty sentences
31
+ n_samples = len(ds)
32
+ ds = ds.filter(lambda x: filter_sample(x))
33
+ n_left = len(ds)
34
+ log = f"Filtered {n_samples - n_left} samples from {n_samples} in {split}"
35
+ with open(log_file_path, "a") as f:
36
+ f.write(log + "\n")
37
+ print(log)
38
+
39
+ dataset[split] = ds
40
+
41
+
42
+ save_path = Path(__file__).parent.parent / "data"
43
+ for split in dataset:
44
+ # dataset[split].to_parquet(save_path / f"{split}-00000-of-00001.parquet")
45
+ dataset[split].to_json(save_path / f"{split}.jsonl.gz", compression="gzip")
46
+
47
+
48
+
49
+
50
+ ds = load_dataset(tasks[0].metadata.dataset["path"])