holylovenia commited on
Commit
c1b6d9b
1 Parent(s): 71924e2

Upload ud_id_csui.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. ud_id_csui.py +26 -30
ud_id_csui.py CHANGED
@@ -19,10 +19,10 @@ from typing import Dict, List, Tuple
19
  import datasets
20
  from conllu import TokenList
21
 
22
- from nusacrowd.utils import schemas
23
- from nusacrowd.utils.common_parser import load_ud_data, load_ud_data_as_nusantara_kb
24
- from nusacrowd.utils.configs import NusantaraConfig
25
- from nusacrowd.utils.constants import Tasks
26
 
27
  _CITATION = """\
28
  @article {10.3844/jcssp.2020.1585.1597,
@@ -71,45 +71,45 @@ _SUPPORTED_TASKS = [Tasks.DEPENDENCY_PARSING, Tasks.MACHINE_TRANSLATION, Tasks.P
71
 
72
  _SOURCE_VERSION = "1.0.0"
73
 
74
- _NUSANTARA_VERSION = "1.0.0"
75
 
76
 
77
  class UdIdCsuiDataset(datasets.GeneratorBasedBuilder):
78
  """Treebank of formal Indonesian news which consists of 1030 sentences (28K words)"""
79
 
80
  SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
81
- NUSANTARA_VERSION = datasets.Version(_NUSANTARA_VERSION)
82
 
83
  # source: https://universaldependencies.org/u/pos/
84
  UPOS_TAGS = ["ADJ", "ADP", "ADV", "AUX", "CCONJ", "DET", "INTJ", "NOUN", "NUM", "PART", "PRON", "PROPN", "PUNCT", "SCONJ", "SYM", "VERB", "X"]
85
 
86
  BUILDER_CONFIGS = [
87
- NusantaraConfig(
88
  name=f"{_DATASETNAME}_source",
89
  version=SOURCE_VERSION,
90
  description=f"{_DATASETNAME} source schema",
91
  schema="source",
92
  subset_id=f"{_DATASETNAME}",
93
  ),
94
- NusantaraConfig(
95
- name=f"{_DATASETNAME}_nusantara_kb",
96
- version=NUSANTARA_VERSION,
97
  description=f"{_DATASETNAME} Nusantara KB schema",
98
- schema="nusantara_kb",
99
  subset_id=f"{_DATASETNAME}",
100
  ),
101
- NusantaraConfig(
102
- name=f"{_DATASETNAME}_nusantara_t2t",
103
- version=NUSANTARA_VERSION,
104
  description=f"{_DATASETNAME} Nusantara Text to Text schema",
105
- schema="nusantara_t2t",
106
  subset_id=f"{_DATASETNAME}",
107
  ),
108
- NusantaraConfig(
109
- name=f"{_DATASETNAME}_nusantara_seq_label",
110
- version=NUSANTARA_VERSION,
111
  description=f"{_DATASETNAME} Nusantara Seq Label schema",
112
- schema="nusantara_seq_label",
113
  subset_id=f"{_DATASETNAME}",
114
  ),
115
  ]
@@ -139,13 +139,13 @@ class UdIdCsuiDataset(datasets.GeneratorBasedBuilder):
139
  }
140
  )
141
 
142
- elif self.config.schema == "nusantara_kb":
143
  features = schemas.kb_features
144
 
145
- elif self.config.schema == "nusantara_t2t":
146
  features = schemas.text2text_features
147
 
148
- elif self.config.schema == "nusantara_seq_label":
149
  features = schemas.seq_label_features(self.UPOS_TAGS)
150
 
151
  else:
@@ -202,10 +202,10 @@ class UdIdCsuiDataset(datasets.GeneratorBasedBuilder):
202
  if self.config.schema == "source":
203
  pass
204
 
205
- elif self.config.schema == "nusantara_kb":
206
- dataset = load_ud_data_as_nusantara_kb(filepath, dataset)
207
 
208
- elif self.config.schema == "nusantara_t2t":
209
  dataset = list(
210
  map(
211
  lambda d: {
@@ -219,7 +219,7 @@ class UdIdCsuiDataset(datasets.GeneratorBasedBuilder):
219
  )
220
  )
221
 
222
- elif self.config.schema == "nusantara_seq_label":
223
  dataset = list(
224
  map(
225
  lambda d: {
@@ -236,7 +236,3 @@ class UdIdCsuiDataset(datasets.GeneratorBasedBuilder):
236
 
237
  for key, example in enumerate(dataset):
238
  yield key, example
239
-
240
-
241
- if __name__ == "__main__":
242
- datasets.load_dataset(__file__)
 
19
  import datasets
20
  from conllu import TokenList
21
 
22
+ from seacrowd.utils import schemas
23
+ from seacrowd.utils.common_parser import load_ud_data, load_ud_data_as_seacrowd_kb
24
+ from seacrowd.utils.configs import SEACrowdConfig
25
+ from seacrowd.utils.constants import Tasks
26
 
27
  _CITATION = """\
28
  @article {10.3844/jcssp.2020.1585.1597,
 
71
 
72
  _SOURCE_VERSION = "1.0.0"
73
 
74
+ _SEACROWD_VERSION = "2024.06.20"
75
 
76
 
77
  class UdIdCsuiDataset(datasets.GeneratorBasedBuilder):
78
  """Treebank of formal Indonesian news which consists of 1030 sentences (28K words)"""
79
 
80
  SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
81
+ SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
82
 
83
  # source: https://universaldependencies.org/u/pos/
84
  UPOS_TAGS = ["ADJ", "ADP", "ADV", "AUX", "CCONJ", "DET", "INTJ", "NOUN", "NUM", "PART", "PRON", "PROPN", "PUNCT", "SCONJ", "SYM", "VERB", "X"]
85
 
86
  BUILDER_CONFIGS = [
87
+ SEACrowdConfig(
88
  name=f"{_DATASETNAME}_source",
89
  version=SOURCE_VERSION,
90
  description=f"{_DATASETNAME} source schema",
91
  schema="source",
92
  subset_id=f"{_DATASETNAME}",
93
  ),
94
+ SEACrowdConfig(
95
+ name=f"{_DATASETNAME}_seacrowd_kb",
96
+ version=SEACROWD_VERSION,
97
  description=f"{_DATASETNAME} Nusantara KB schema",
98
+ schema="seacrowd_kb",
99
  subset_id=f"{_DATASETNAME}",
100
  ),
101
+ SEACrowdConfig(
102
+ name=f"{_DATASETNAME}_seacrowd_t2t",
103
+ version=SEACROWD_VERSION,
104
  description=f"{_DATASETNAME} Nusantara Text to Text schema",
105
+ schema="seacrowd_t2t",
106
  subset_id=f"{_DATASETNAME}",
107
  ),
108
+ SEACrowdConfig(
109
+ name=f"{_DATASETNAME}_seacrowd_seq_label",
110
+ version=SEACROWD_VERSION,
111
  description=f"{_DATASETNAME} Nusantara Seq Label schema",
112
+ schema="seacrowd_seq_label",
113
  subset_id=f"{_DATASETNAME}",
114
  ),
115
  ]
 
139
  }
140
  )
141
 
142
+ elif self.config.schema == "seacrowd_kb":
143
  features = schemas.kb_features
144
 
145
+ elif self.config.schema == "seacrowd_t2t":
146
  features = schemas.text2text_features
147
 
148
+ elif self.config.schema == "seacrowd_seq_label":
149
  features = schemas.seq_label_features(self.UPOS_TAGS)
150
 
151
  else:
 
202
  if self.config.schema == "source":
203
  pass
204
 
205
+ elif self.config.schema == "seacrowd_kb":
206
+ dataset = load_ud_data_as_seacrowd_kb(filepath, dataset)
207
 
208
+ elif self.config.schema == "seacrowd_t2t":
209
  dataset = list(
210
  map(
211
  lambda d: {
 
219
  )
220
  )
221
 
222
+ elif self.config.schema == "seacrowd_seq_label":
223
  dataset = list(
224
  map(
225
  lambda d: {
 
236
 
237
  for key, example in enumerate(dataset):
238
  yield key, example