holylovenia commited on
Commit
39e8d59
·
verified ·
1 Parent(s): 2fa8d64

Upload identic.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. identic.py +29 -29
identic.py CHANGED
@@ -24,10 +24,10 @@ from typing import Dict, List, Tuple
24
  import datasets
25
  import pandas as pd
26
 
27
- from nusacrowd.utils import schemas
28
- from nusacrowd.utils.common_parser import load_ud_data
29
- from nusacrowd.utils.configs import NusantaraConfig
30
- from nusacrowd.utils.constants import Tasks
31
 
32
  _CITATION = """\
33
  @inproceedings{larasati-2012-identic,
@@ -72,7 +72,7 @@ _SUPPORTED_TASKS = [Tasks.MACHINE_TRANSLATION, Tasks.POS_TAGGING]
72
 
73
  _SOURCE_VERSION = "1.0.0"
74
 
75
- _NUSANTARA_VERSION = "1.0.0"
76
 
77
  _LANGUAGES = ["ind", "eng"]
78
 
@@ -110,22 +110,22 @@ tagsets_map = {
110
  }
111
 
112
 
113
- def nusantara_config_constructor(version, variation=None, task="source", lang="id"):
114
  if variation not in SOURCE_VARIATION:
115
  raise NotImplementedError("'{var}' is not available".format(var=variation))
116
 
117
  ver = datasets.Version(version)
118
 
119
  if task == "seq_label":
120
- return NusantaraConfig(
121
- name="identic_{lang}_nusantara_seq_label".format(lang=lang),
122
  version=ver,
123
  description="IDENTIC {lang} source schema".format(lang=lang),
124
- schema="nusantara_seq_label",
125
  subset_id="identic",
126
  )
127
  else:
128
- return NusantaraConfig(
129
  name="identic_{var}_{task}".format(var=variation, task=task),
130
  version=ver,
131
  description="IDENTIC {var} source schema".format(var=variation),
@@ -149,7 +149,7 @@ class IdenticDataset(datasets.GeneratorBasedBuilder):
149
  """
150
 
151
  SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
152
- NUSANTARA_VERSION = datasets.Version(_NUSANTARA_VERSION)
153
 
154
  # Details of the tagsets in https://septinalarasati.com/morphind/
155
  TAGSETS = [
@@ -234,45 +234,45 @@ class IdenticDataset(datasets.GeneratorBasedBuilder):
234
 
235
  BUILDER_CONFIGS = (
236
  [
237
- NusantaraConfig(
238
  name="identic_source",
239
  version=SOURCE_VERSION,
240
  description="identic source schema",
241
  schema="source",
242
  subset_id="identic",
243
  ),
244
- NusantaraConfig(
245
  name="identic_id_source",
246
  version=SOURCE_VERSION,
247
  description="identic source schema",
248
  schema="source",
249
  subset_id="identic",
250
  ),
251
- NusantaraConfig(
252
  name="identic_en_source",
253
  version=SOURCE_VERSION,
254
  description="identic source schema",
255
  schema="source",
256
  subset_id="identic",
257
  ),
258
- NusantaraConfig(
259
- name="identic_nusantara_t2t",
260
- version=NUSANTARA_VERSION,
261
  description="Identic Nusantara schema",
262
- schema="nusantara_t2t",
263
  subset_id="identic",
264
  ),
265
- NusantaraConfig(
266
- name="identic_nusantara_seq_label",
267
- version=NUSANTARA_VERSION,
268
  description="Identic Nusantara schema",
269
- schema="nusantara_seq_label",
270
  subset_id="identic",
271
  ),
272
  ]
273
- + [nusantara_config_constructor(_NUSANTARA_VERSION, var) for var in SOURCE_VARIATION]
274
- + [nusantara_config_constructor(_NUSANTARA_VERSION, var, "nusantara_t2t") for var in SOURCE_VARIATION]
275
- + [nusantara_config_constructor(_NUSANTARA_VERSION, "raw", task="seq_label", lang=lang) for lang in ["en", "id"]]
276
  )
277
 
278
  DEFAULT_CONFIG_NAME = "identic_source"
@@ -303,10 +303,10 @@ class IdenticDataset(datasets.GeneratorBasedBuilder):
303
  }
304
  )
305
 
306
- elif self.config.schema == "nusantara_t2t":
307
  features = schemas.text2text_features
308
 
309
- elif self.config.schema == "nusantara_seq_label":
310
  features = schemas.seq_label_features(self.TAGSETS)
311
 
312
  return datasets.DatasetInfo(
@@ -368,7 +368,7 @@ class IdenticDataset(datasets.GeneratorBasedBuilder):
368
  for key, example in enumerate(load_ud_data(path)):
369
  yield key, example
370
 
371
- elif self.config.schema == "nusantara_t2t":
372
  for id, row in df.iterrows():
373
  yield id, {
374
  "id": str(id),
@@ -378,7 +378,7 @@ class IdenticDataset(datasets.GeneratorBasedBuilder):
378
  "text_2_name": "eng",
379
  }
380
 
381
- elif self.config.schema == "nusantara_seq_label":
382
  if lang is None:
383
  lang = "id"
384
  path = filepath.parent / "{lang}.npp.conll".format(lang=lang)
 
24
  import datasets
25
  import pandas as pd
26
 
27
+ from seacrowd.utils import schemas
28
+ from seacrowd.utils.common_parser import load_ud_data
29
+ from seacrowd.utils.configs import SEACrowdConfig
30
+ from seacrowd.utils.constants import Tasks
31
 
32
  _CITATION = """\
33
  @inproceedings{larasati-2012-identic,
 
72
 
73
  _SOURCE_VERSION = "1.0.0"
74
 
75
+ _SEACROWD_VERSION = "2024.06.20"
76
 
77
  _LANGUAGES = ["ind", "eng"]
78
 
 
110
  }
111
 
112
 
113
+ def seacrowd_config_constructor(version, variation=None, task="source", lang="id"):
114
  if variation not in SOURCE_VARIATION:
115
  raise NotImplementedError("'{var}' is not available".format(var=variation))
116
 
117
  ver = datasets.Version(version)
118
 
119
  if task == "seq_label":
120
+ return SEACrowdConfig(
121
+ name="identic_{lang}_seacrowd_seq_label".format(lang=lang),
122
  version=ver,
123
  description="IDENTIC {lang} source schema".format(lang=lang),
124
+ schema="seacrowd_seq_label",
125
  subset_id="identic",
126
  )
127
  else:
128
+ return SEACrowdConfig(
129
  name="identic_{var}_{task}".format(var=variation, task=task),
130
  version=ver,
131
  description="IDENTIC {var} source schema".format(var=variation),
 
149
  """
150
 
151
  SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
152
+ SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
153
 
154
  # Details of the tagsets in https://septinalarasati.com/morphind/
155
  TAGSETS = [
 
234
 
235
  BUILDER_CONFIGS = (
236
  [
237
+ SEACrowdConfig(
238
  name="identic_source",
239
  version=SOURCE_VERSION,
240
  description="identic source schema",
241
  schema="source",
242
  subset_id="identic",
243
  ),
244
+ SEACrowdConfig(
245
  name="identic_id_source",
246
  version=SOURCE_VERSION,
247
  description="identic source schema",
248
  schema="source",
249
  subset_id="identic",
250
  ),
251
+ SEACrowdConfig(
252
  name="identic_en_source",
253
  version=SOURCE_VERSION,
254
  description="identic source schema",
255
  schema="source",
256
  subset_id="identic",
257
  ),
258
+ SEACrowdConfig(
259
+ name="identic_seacrowd_t2t",
260
+ version=SEACROWD_VERSION,
261
  description="Identic Nusantara schema",
262
+ schema="seacrowd_t2t",
263
  subset_id="identic",
264
  ),
265
+ SEACrowdConfig(
266
+ name="identic_seacrowd_seq_label",
267
+ version=SEACROWD_VERSION,
268
  description="Identic Nusantara schema",
269
+ schema="seacrowd_seq_label",
270
  subset_id="identic",
271
  ),
272
  ]
273
+ + [seacrowd_config_constructor(_SEACROWD_VERSION, var) for var in SOURCE_VARIATION]
274
+ + [seacrowd_config_constructor(_SEACROWD_VERSION, var, "seacrowd_t2t") for var in SOURCE_VARIATION]
275
+ + [seacrowd_config_constructor(_SEACROWD_VERSION, "raw", task="seq_label", lang=lang) for lang in ["en", "id"]]
276
  )
277
 
278
  DEFAULT_CONFIG_NAME = "identic_source"
 
303
  }
304
  )
305
 
306
+ elif self.config.schema == "seacrowd_t2t":
307
  features = schemas.text2text_features
308
 
309
+ elif self.config.schema == "seacrowd_seq_label":
310
  features = schemas.seq_label_features(self.TAGSETS)
311
 
312
  return datasets.DatasetInfo(
 
368
  for key, example in enumerate(load_ud_data(path)):
369
  yield key, example
370
 
371
+ elif self.config.schema == "seacrowd_t2t":
372
  for id, row in df.iterrows():
373
  yield id, {
374
  "id": str(id),
 
378
  "text_2_name": "eng",
379
  }
380
 
381
+ elif self.config.schema == "seacrowd_seq_label":
382
  if lang is None:
383
  lang = "id"
384
  path = filepath.parent / "{lang}.npp.conll".format(lang=lang)