holylovenia
commited on
Upload kopi_cc_news.py with huggingface_hub
Browse files- kopi_cc_news.py +13 -13
kopi_cc_news.py
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
"""
|
17 |
KoPI-CC_NEWS corpus
|
18 |
|
19 |
-
[
|
20 |
"""
|
21 |
|
22 |
import json
|
@@ -25,16 +25,16 @@ from typing import List
|
|
25 |
import datasets
|
26 |
import zstandard as zstd
|
27 |
|
28 |
-
from
|
29 |
-
from
|
30 |
-
from
|
31 |
DEFAULT_SOURCE_VIEW_NAME, Tasks)
|
32 |
|
33 |
_DATASETNAME = "kopi_cc_news"
|
34 |
_LOCAL = False
|
35 |
_LANGUAGES = ["ind"] # We follow ISO639-3 language code (https://iso639-3.sil.org/code_tables/639/data)
|
36 |
_SOURCE_VIEW_NAME = DEFAULT_SOURCE_VIEW_NAME
|
37 |
-
_UNIFIED_VIEW_NAME =
|
38 |
_SUPPORTED_TASKS = [Tasks.SELF_SUPERVISED_PRETRAINING]
|
39 |
_URL = "https://commoncrawl.org/"
|
40 |
_CITATION = """\
|
@@ -57,18 +57,18 @@ _ALL_CONFIG = _YEAR + ["all"]
|
|
57 |
|
58 |
_SOURCE_VERSION = "2018.12.01"
|
59 |
|
60 |
-
|
61 |
|
62 |
|
63 |
-
def
|
64 |
-
"""Construct
|
65 |
-
if schema != "source" and schema != "
|
66 |
raise ValueError(f"Invalid schema: {schema}")
|
67 |
|
68 |
if year == "":
|
69 |
raise ValueError(f"Snapshot is required. Choose one of these Snapshot: {_ALL_CONFIG}.")
|
70 |
elif year in _ALL_CONFIG:
|
71 |
-
return
|
72 |
name=f"{_DATASETNAME}_{year}_{schema}",
|
73 |
version=datasets.Version(version),
|
74 |
description=f"KoPI-CC_News with {schema} schema for {year}",
|
@@ -83,7 +83,7 @@ class KoPICCNEWS(datasets.GeneratorBasedBuilder):
|
|
83 |
|
84 |
DEFAULT_CONFIG_NAME = "2016"
|
85 |
|
86 |
-
BUILDER_CONFIGS = [
|
87 |
|
88 |
def _info(self):
|
89 |
if self.config.schema == "source":
|
@@ -95,7 +95,7 @@ class KoPICCNEWS(datasets.GeneratorBasedBuilder):
|
|
95 |
"meta": datasets.Value("string"),
|
96 |
}
|
97 |
)
|
98 |
-
elif self.config.schema == "
|
99 |
features = schemas.self_supervised_pretraining.features
|
100 |
|
101 |
return datasets.DatasetInfo(
|
@@ -131,7 +131,7 @@ class KoPICCNEWS(datasets.GeneratorBasedBuilder):
|
|
131 |
for line in f:
|
132 |
if line:
|
133 |
example = json.loads(line)
|
134 |
-
if self.config.schema == "
|
135 |
yield id_, {"id": str(id_), "text": example["text"]}
|
136 |
id_ += 1
|
137 |
else:
|
|
|
16 |
"""
|
17 |
KoPI-CC_NEWS corpus
|
18 |
|
19 |
+
[seacrowd_schema_name] = ssp
|
20 |
"""
|
21 |
|
22 |
import json
|
|
|
25 |
import datasets
|
26 |
import zstandard as zstd
|
27 |
|
28 |
+
from seacrowd.utils import schemas
|
29 |
+
from seacrowd.utils.configs import SEACrowdConfig
|
30 |
+
from seacrowd.utils.constants import (DEFAULT_SEACROWD_VIEW_NAME,
|
31 |
DEFAULT_SOURCE_VIEW_NAME, Tasks)
|
32 |
|
33 |
_DATASETNAME = "kopi_cc_news"
|
34 |
_LOCAL = False
|
35 |
_LANGUAGES = ["ind"] # We follow ISO639-3 language code (https://iso639-3.sil.org/code_tables/639/data)
|
36 |
_SOURCE_VIEW_NAME = DEFAULT_SOURCE_VIEW_NAME
|
37 |
+
_UNIFIED_VIEW_NAME = DEFAULT_SEACROWD_VIEW_NAME
|
38 |
_SUPPORTED_TASKS = [Tasks.SELF_SUPERVISED_PRETRAINING]
|
39 |
_URL = "https://commoncrawl.org/"
|
40 |
_CITATION = """\
|
|
|
57 |
|
58 |
_SOURCE_VERSION = "2018.12.01"
|
59 |
|
60 |
+
_SEACROWD_VERSION = "2024.06.20"
|
61 |
|
62 |
|
63 |
+
def seacrowd_config_constructor(year, schema, version):
|
64 |
+
"""Construct SEACrowdConfig"""
|
65 |
+
if schema != "source" and schema != "seacrowd_ssp":
|
66 |
raise ValueError(f"Invalid schema: {schema}")
|
67 |
|
68 |
if year == "":
|
69 |
raise ValueError(f"Snapshot is required. Choose one of these Snapshot: {_ALL_CONFIG}.")
|
70 |
elif year in _ALL_CONFIG:
|
71 |
+
return SEACrowdConfig(
|
72 |
name=f"{_DATASETNAME}_{year}_{schema}",
|
73 |
version=datasets.Version(version),
|
74 |
description=f"KoPI-CC_News with {schema} schema for {year}",
|
|
|
83 |
|
84 |
DEFAULT_CONFIG_NAME = "2016"
|
85 |
|
86 |
+
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]
|
87 |
|
88 |
def _info(self):
|
89 |
if self.config.schema == "source":
|
|
|
95 |
"meta": datasets.Value("string"),
|
96 |
}
|
97 |
)
|
98 |
+
elif self.config.schema == "seacrowd_ssp":
|
99 |
features = schemas.self_supervised_pretraining.features
|
100 |
|
101 |
return datasets.DatasetInfo(
|
|
|
131 |
for line in f:
|
132 |
if line:
|
133 |
example = json.loads(line)
|
134 |
+
if self.config.schema == "seacrowd_ssp":
|
135 |
yield id_, {"id": str(id_), "text": example["text"]}
|
136 |
id_ += 1
|
137 |
else:
|