Filippo B commited on
Commit
950e962
1 Parent(s): bd382a2

Update loader script to use 16 labels

Browse files
Files changed (2) hide show
  1. README.md +43 -0
  2. osdg_cd.py +5 -5
README.md CHANGED
@@ -16,6 +16,49 @@ task_categories:
16
  task_ids:
17
  - natural-language-inference
18
  pretty_name: OSDG Community Dataset (OSDG-CD)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  ---
20
  # Dataset Card for OSDG-CD
21
 
 
16
  task_ids:
17
  - natural-language-inference
18
  pretty_name: OSDG Community Dataset (OSDG-CD)
19
+ dataset_info:
20
+ config_name: main_config
21
+ features:
22
+ - name: doi
23
+ dtype: string
24
+ - name: text_id
25
+ dtype: string
26
+ - name: text
27
+ dtype: string
28
+ - name: sdg
29
+ dtype: uint16
30
+ - name: label
31
+ dtype:
32
+ class_label:
33
+ names:
34
+ '0': SDG 1
35
+ '1': SDG 2
36
+ '2': SDG 3
37
+ '3': SDG 4
38
+ '4': SDG 5
39
+ '5': SDG 6
40
+ '6': SDG 7
41
+ '7': SDG 8
42
+ '8': SDG 9
43
+ '9': SDG 10
44
+ '10': SDG 11
45
+ '11': SDG 12
46
+ '12': SDG 13
47
+ '13': SDG 14
48
+ '14': SDG 15
49
+ '15': SDG 16
50
+ - name: labels_negative
51
+ dtype: uint16
52
+ - name: labels_positive
53
+ dtype: uint16
54
+ - name: agreement
55
+ dtype: float32
56
+ splits:
57
+ - name: train
58
+ num_bytes: 29955216
59
+ num_examples: 42065
60
+ download_size: 29574964
61
+ dataset_size: 29955216
62
  ---
63
  # Dataset Card for OSDG-CD
64
 
osdg_cd.py CHANGED
@@ -120,7 +120,7 @@ class OSDGCD(datasets.GeneratorBasedBuilder):
120
  "text_id": datasets.Value("string"),
121
  "text": datasets.Value("string"),
122
  "sdg": datasets.Value("uint16"),
123
- "label": datasets.ClassLabel(num_classes=15, names=[f"SDG {sdg}" for sdg in range(1, 16)]),
124
  "labels_negative": datasets.Value("uint16"),
125
  "labels_positive": datasets.Value("uint16"),
126
  "agreement": datasets.Value("float"),
@@ -145,10 +145,10 @@ class OSDGCD(datasets.GeneratorBasedBuilder):
145
  def _generate_examples(self, filepath):
146
  """This function returns the examples in the raw (text) form."""
147
  logger.info("generating examples from = %s", filepath)
148
- key = 0
149
  with open(filepath, encoding="utf-8") as f:
150
  osdg = csv.DictReader(f, delimiter="\t")
151
  for row in osdg:
152
- row["label"] = int(row["sdg"]) - 1
153
- yield key, row
154
- key += 1
 
 
120
  "text_id": datasets.Value("string"),
121
  "text": datasets.Value("string"),
122
  "sdg": datasets.Value("uint16"),
123
+ "label": datasets.ClassLabel(num_classes=16, names=[f"SDG {sdg}" for sdg in range(1, 17)]),
124
  "labels_negative": datasets.Value("uint16"),
125
  "labels_positive": datasets.Value("uint16"),
126
  "agreement": datasets.Value("float"),
 
145
  def _generate_examples(self, filepath):
146
  """This function returns the examples in the raw (text) form."""
147
  logger.info("generating examples from = %s", filepath)
 
148
  with open(filepath, encoding="utf-8") as f:
149
  osdg = csv.DictReader(f, delimiter="\t")
150
  for row in osdg:
151
+ id_ = row["text_id"]
152
+ sdg = int(row["sdg"])
153
+ row["label"] = f"SDG {sdg}"
154
+ yield id_, row