holylovenia commited on
Commit
d54147c
1 Parent(s): ed1b0ad

Upload kopi_cc.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. kopi_cc.py +14 -14
kopi_cc.py CHANGED
@@ -16,7 +16,7 @@
16
  """
17
  KoPI-CC corpus
18
 
19
- [nusantara_schema_name] = ssp
20
  """
21
 
22
  import gzip
@@ -26,16 +26,16 @@ from typing import List
26
  import datasets
27
  import zstandard as zstd
28
 
29
- from nusacrowd.utils import schemas
30
- from nusacrowd.utils.configs import NusantaraConfig
31
- from nusacrowd.utils.constants import (DEFAULT_NUSANTARA_VIEW_NAME,
32
  DEFAULT_SOURCE_VIEW_NAME, Tasks)
33
 
34
  _DATASETNAME = "kopi_cc"
35
  _LANGUAGES = ["ind"]
36
  _LOCAL = False
37
  _SOURCE_VIEW_NAME = DEFAULT_SOURCE_VIEW_NAME
38
- _UNIFIED_VIEW_NAME = DEFAULT_NUSANTARA_VIEW_NAME
39
  _URL = "https://commoncrawl.org/"
40
  _CITATION = """\
41
  @ARTICLE{2022arXiv220106642A,
@@ -112,18 +112,18 @@ _ALL_CONFIG = ["all-raw", "all-dedup", "all-neardup", "all-neardup_clean"] + _SN
112
 
113
  _SOURCE_VERSION = "2018.12.01"
114
 
115
- _NUSANTARA_VERSION = "1.0.0"
116
 
117
 
118
- def nusantara_config_constructor(snapshot, schema, version):
119
- """Construct NusantaraConfig"""
120
- if schema != "source" and schema != "nusantara_ssp":
121
  raise ValueError(f"Invalid schema: {schema}")
122
 
123
  if snapshot == "":
124
  raise ValueError(f"Snapshot is required. Choose one of these Snapshot: {_ALL_CONFIG}.")
125
  elif snapshot in _SNAP_CONFIG + _ALL_CONFIG:
126
- return NusantaraConfig(
127
  name=f"{_DATASETNAME}_{snapshot}_{schema}",
128
  version=datasets.Version(version),
129
  description=f"KoPI-CC with {schema} schema for {snapshot}",
@@ -138,7 +138,7 @@ class KoPICC(datasets.GeneratorBasedBuilder):
138
 
139
  DEFAULT_CONFIG_NAME = "2021_17_dedup"
140
 
141
- BUILDER_CONFIGS = [nusantara_config_constructor(sn, "source", _SOURCE_VERSION) for sn in _ALL_CONFIG] + [nusantara_config_constructor(sn, "nusantara_ssp", _NUSANTARA_VERSION) for sn in _ALL_CONFIG]
142
 
143
  def _info(self):
144
  if self.config.schema == "source":
@@ -150,7 +150,7 @@ class KoPICC(datasets.GeneratorBasedBuilder):
150
  "meta": datasets.Value("string"),
151
  }
152
  )
153
- elif self.config.schema == "nusantara_ssp":
154
  features = schemas.self_supervised_pretraining.features
155
 
156
  return datasets.DatasetInfo(
@@ -201,7 +201,7 @@ class KoPICC(datasets.GeneratorBasedBuilder):
201
  meta["identification"] = example["metadata"]["identification"]
202
  meta["annotations"] = example["metadata"]["annotation"]
203
  meta["line_identifications"] = example["metadata"]["sentence_identifications"]
204
- if self.config.schema == "nusantara_ssp":
205
  yield id_, {"id": str(id_), "text": example["content"]}
206
  id_ += 1
207
  else:
@@ -212,7 +212,7 @@ class KoPICC(datasets.GeneratorBasedBuilder):
212
  for line in f:
213
  if line:
214
  example = json.loads(line)
215
- if self.config.schema == "nusantara_ssp":
216
  yield id_, {"id": str(id_), "text": example["text"]}
217
  id_ += 1
218
  else:
 
16
  """
17
  KoPI-CC corpus
18
 
19
+ [seacrowd_schema_name] = ssp
20
  """
21
 
22
  import gzip
 
26
  import datasets
27
  import zstandard as zstd
28
 
29
+ from seacrowd.utils import schemas
30
+ from seacrowd.utils.configs import SEACrowdConfig
31
+ from seacrowd.utils.constants import (DEFAULT_SEACROWD_VIEW_NAME,
32
  DEFAULT_SOURCE_VIEW_NAME, Tasks)
33
 
34
  _DATASETNAME = "kopi_cc"
35
  _LANGUAGES = ["ind"]
36
  _LOCAL = False
37
  _SOURCE_VIEW_NAME = DEFAULT_SOURCE_VIEW_NAME
38
+ _UNIFIED_VIEW_NAME = DEFAULT_SEACROWD_VIEW_NAME
39
  _URL = "https://commoncrawl.org/"
40
  _CITATION = """\
41
  @ARTICLE{2022arXiv220106642A,
 
112
 
113
  _SOURCE_VERSION = "2018.12.01"
114
 
115
+ _SEACROWD_VERSION = "2024.06.20"
116
 
117
 
118
+ def seacrowd_config_constructor(snapshot, schema, version):
119
+ """Construct SEACrowdConfig"""
120
+ if schema != "source" and schema != "seacrowd_ssp":
121
  raise ValueError(f"Invalid schema: {schema}")
122
 
123
  if snapshot == "":
124
  raise ValueError(f"Snapshot is required. Choose one of these Snapshot: {_ALL_CONFIG}.")
125
  elif snapshot in _SNAP_CONFIG + _ALL_CONFIG:
126
+ return SEACrowdConfig(
127
  name=f"{_DATASETNAME}_{snapshot}_{schema}",
128
  version=datasets.Version(version),
129
  description=f"KoPI-CC with {schema} schema for {snapshot}",
 
138
 
139
  DEFAULT_CONFIG_NAME = "2021_17_dedup"
140
 
141
+ BUILDER_CONFIGS = [seacrowd_config_constructor(sn, "source", _SOURCE_VERSION) for sn in _ALL_CONFIG] + [seacrowd_config_constructor(sn, "seacrowd_ssp", _SEACROWD_VERSION) for sn in _ALL_CONFIG]
142
 
143
  def _info(self):
144
  if self.config.schema == "source":
 
150
  "meta": datasets.Value("string"),
151
  }
152
  )
153
+ elif self.config.schema == "seacrowd_ssp":
154
  features = schemas.self_supervised_pretraining.features
155
 
156
  return datasets.DatasetInfo(
 
201
  meta["identification"] = example["metadata"]["identification"]
202
  meta["annotations"] = example["metadata"]["annotation"]
203
  meta["line_identifications"] = example["metadata"]["sentence_identifications"]
204
+ if self.config.schema == "seacrowd_ssp":
205
  yield id_, {"id": str(id_), "text": example["content"]}
206
  id_ += 1
207
  else:
 
212
  for line in f:
213
  if line:
214
  example = json.loads(line)
215
+ if self.config.schema == "seacrowd_ssp":
216
  yield id_, {"id": str(id_), "text": example["text"]}
217
  id_ += 1
218
  else: