Datasets:

Modalities:
Text
Formats:
arrow
Languages:
English
ArXiv:
Libraries:
Datasets
License:
AnnaWegmann commited on
Commit
906d1d0
·
verified ·
1 Parent(s): f820a0e

Delete AV.py

Browse files
Files changed (1) hide show
  1. AV.py +0 -65
AV.py DELETED
@@ -1,65 +0,0 @@
1
- """ generated with GPT-4o """
2
- from datasets import GeneratorBasedBuilder, DatasetInfo, SplitGenerator, Split, BuilderConfig
3
- import datasets
4
- import csv
5
- import pyarrow as pa
6
- import os
7
-
8
- class CustomConfig(BuilderConfig):
9
- def __init__(self, **kwargs):
10
- super().__init__(**kwargs)
11
-
12
- class MyDataset(GeneratorBasedBuilder):
13
- BUILDER_CONFIGS = [
14
- CustomConfig(
15
- name="Contrastive Learning",
16
- version=datasets.Version("1.0.0"),
17
- description="Load from Arrow files"
18
- ),
19
- CustomConfig(
20
- name="Thresholding",
21
- version=datasets.Version("1.0.0"),
22
- description="Load from CSV files"
23
- ),
24
- ]
25
-
26
- def _info(self):
27
- return DatasetInfo()
28
-
29
- def _split_generators(self, dl_manager):
30
- if self.config.name == "Contrastive Learning":
31
- return [
32
- SplitGenerator(name=Split.TRAIN, gen_kwargs={"filepath": "train/data-00000-of-00001.arrow"}),
33
- SplitGenerator(name=Split.VALIDATION, gen_kwargs={"filepath": "validation/data-00000-of-00001.arrow"}),
34
- SplitGenerator(name=Split.TEST, gen_kwargs={"filepath": "test/data-00000-of-00001.arrow"}),
35
- ]
36
-
37
- elif self.config.name == "Thresholding":
38
- return [
39
- SplitGenerator(name=Split.TRAIN, gen_kwargs={"filepath": "train/train.csv"}),
40
- SplitGenerator(name=Split.VALIDATION, gen_kwargs={"filepath": "validation/validation.csv"}),
41
- SplitGenerator(name=Split.TEST, gen_kwargs={"filepath": "test/test.csv"}),
42
- ]
43
-
44
- else:
45
- raise ValueError(f"Unsupported config: {self.config.name}")
46
-
47
- def _generate_examples(self, filepath):
48
- if filepath.endswith(".arrow"):
49
- with open(filepath, "rb") as f:
50
- try:
51
- table = pa.ipc.RecordBatchFileReader(f).read_all()
52
- except Exception as e:
53
- raise ValueError(f"Could not read Arrow file: {filepath}") from e
54
- data = table.to_pydict()
55
- for i in range(len(next(iter(data.values())))):
56
- yield i, {k: data[k][i] for k in data}
57
-
58
- elif filepath.endswith(".csv"):
59
- with open(filepath, encoding="utf-8") as f:
60
- reader = csv.DictReader(f)
61
- for i, row in enumerate(reader):
62
- yield i, row
63
-
64
- else:
65
- raise ValueError(f"Unsupported file format: {filepath}")