ngwgsang commited on
Commit
c927fc6
·
verified ·
1 Parent(s): 066bd30

Rename dataset_dict.py to dataset.py

Browse files
Files changed (2) hide show
  1. dataset.py +76 -0
  2. dataset_dict.py +0 -9
dataset.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+
3
+ _CITATION = """\
4
+
5
+ """
6
+
7
+ _DESCRIPTION = """\
8
+ VietDrift is a dataset for detecting semantic shift in Vietnamese paraphrases. \
9
+ It has two phases: Phase 1 is binary classification (shift/no-shift), \
10
+ and Phase 2 is multi-label classification of 9 fine-grained shift types.
11
+ """
12
+
13
+ _HOMEPAGE = "https://huggingface.co/datasets/ngwgsang/vietdrift"
14
+
15
+ _LICENSE = "MIT"
16
+
17
+ _PHASE_CONFIGS = {
18
+ "phase_1": {
19
+ "features": datasets.Features({
20
+ "id": datasets.Value("string"),
21
+ "sentence1": datasets.Value("string"),
22
+ "sentence2": datasets.Value("string"),
23
+ "topic": datasets.Value("string"),
24
+ "coarse_label": datasets.Value("bool"),
25
+ }),
26
+ },
27
+ "phase_2": {
28
+ "features": datasets.Features({
29
+ "id": datasets.Value("string"),
30
+ "sentence1": datasets.Value("string"),
31
+ "sentence2": datasets.Value("string"),
32
+ "topic": datasets.Value("string"),
33
+ "fine_labels": datasets.Sequence(datasets.Value("string")),
34
+ "agent_ratio": datasets.Value("float32"),
35
+ "theme_ratio": datasets.Value("float32"),
36
+ "action_ratio": datasets.Value("float32"),
37
+ "recipient_ratio": datasets.Value("float32"),
38
+ "time_ratio": datasets.Value("float32"),
39
+ "location_ratio": datasets.Value("float32"),
40
+ "cause_ratio": datasets.Value("float32"),
41
+ "instrument_ratio": datasets.Value("float32"),
42
+ "modality_ratio": datasets.Value("float32"),
43
+ }),
44
+ }
45
+ }
46
+
47
+ class VietDriftConfig(datasets.BuilderConfig):
48
+ def __init__(self, **kwargs):
49
+ super().__init__(**kwargs)
50
+
51
+ class VietDrift(datasets.GeneratorBasedBuilder):
52
+ BUILDER_CONFIGS = [
53
+ VietDriftConfig(name="phase_1", version=datasets.Version("1.0.0"), description="Coarse label binary classification"),
54
+ VietDriftConfig(name="phase_2", version=datasets.Version("1.0.0"), description="Fine-grained multi-label classification"),
55
+ ]
56
+
57
+ DEFAULT_CONFIG_NAME = "phase_1"
58
+
59
+ def _info(self):
60
+ return datasets.DatasetInfo(
61
+ description=_DESCRIPTION,
62
+ features=_PHASE_CONFIGS[self.config.name]["features"],
63
+ supervised_keys=None,
64
+ homepage=_HOMEPAGE,
65
+ license=_LICENSE,
66
+ citation=_CITATION,
67
+ )
68
+
69
+ def _split_generators(self, dl_manager):
70
+ data_dir = f"{self.config.name}"
71
+ return [
72
+ datasets.SplitGenerator(
73
+ name=datasets.Split.TRAIN,
74
+ gen_kwargs={"filepath": dl_manager.download_and_extract(f"{data_dir}/train.csv")},
75
+ ),
76
+ datasets.SplitGenerator(
dataset_dict.py DELETED
@@ -1,9 +0,0 @@
1
- # vietdrift/dataset_dict.py
2
-
3
- from datasets import DatasetDict, load_dataset
4
-
5
- def get_dataset_dict(config_name):
6
- return load_dataset("csv", data_files={
7
- "train": f"{config_name}/train.csv",
8
- "test": f"{config_name}/test.csv"
9
- })