Upload sampiran.py with huggingface_hub
Browse files- sampiran.py +14 -14
sampiran.py
CHANGED
@@ -15,12 +15,12 @@
|
|
15 |
|
16 |
from pathlib import Path
|
17 |
from typing import Dict, List, Tuple
|
18 |
-
from
|
19 |
-
from
|
20 |
|
21 |
import datasets
|
22 |
|
23 |
-
from
|
24 |
|
25 |
# TODO: Add BibTeX citation
|
26 |
_CITATION = """\
|
@@ -52,7 +52,7 @@ _SUPPORTED_TASKS = [Tasks.SELF_SUPERVISED_PRETRAINING]
|
|
52 |
|
53 |
_SOURCE_VERSION = "1.0.0"
|
54 |
|
55 |
-
|
56 |
|
57 |
|
58 |
class SampiranDataset(datasets.GeneratorBasedBuilder):
|
@@ -60,21 +60,21 @@ class SampiranDataset(datasets.GeneratorBasedBuilder):
|
|
60 |
collected from various sources (online)."""
|
61 |
|
62 |
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
63 |
-
|
64 |
|
65 |
BUILDER_CONFIGS = [
|
66 |
-
|
67 |
name="sampiran_source",
|
68 |
version=SOURCE_VERSION,
|
69 |
description="sampiran source schema",
|
70 |
schema="source",
|
71 |
subset_id="sampiran",
|
72 |
),
|
73 |
-
|
74 |
-
name="
|
75 |
-
version=
|
76 |
description="sampiran Nusantara schema",
|
77 |
-
schema="
|
78 |
subset_id="sampiran",
|
79 |
),
|
80 |
]
|
@@ -90,9 +90,9 @@ class SampiranDataset(datasets.GeneratorBasedBuilder):
|
|
90 |
"pantun": datasets.Value("string"),
|
91 |
}
|
92 |
)
|
93 |
-
elif self.config.schema == "
|
94 |
# e.g. features = schemas.kb_features
|
95 |
-
# TODO: Choose your
|
96 |
features = schemas.self_supervised_pretraining.features
|
97 |
|
98 |
return datasets.DatasetInfo(
|
@@ -121,7 +121,7 @@ class SampiranDataset(datasets.GeneratorBasedBuilder):
|
|
121 |
|
122 |
def _generate_examples(self, filepath: Path, split: str = None) -> Tuple[int, Dict]:
|
123 |
"""Yields examples as (key, example) tuples."""
|
124 |
-
if self.config.schema != "source" and self.config.schema != "
|
125 |
raise ValueError(f"Invalid config schema: {self.config.schema}")
|
126 |
|
127 |
# Read the file line by line
|
@@ -135,7 +135,7 @@ class SampiranDataset(datasets.GeneratorBasedBuilder):
|
|
135 |
}
|
136 |
yield id_, ex
|
137 |
|
138 |
-
elif self.config.name == "
|
139 |
with open(filepath, encoding="utf-8") as f:
|
140 |
for id_, row in enumerate(f):
|
141 |
ex = {"id": str(id_), "text": str(row).rstrip()}
|
|
|
15 |
|
16 |
from pathlib import Path
|
17 |
from typing import Dict, List, Tuple
|
18 |
+
from seacrowd.utils.constants import Tasks
|
19 |
+
from seacrowd.utils import schemas
|
20 |
|
21 |
import datasets
|
22 |
|
23 |
+
from seacrowd.utils.configs import SEACrowdConfig
|
24 |
|
25 |
# TODO: Add BibTeX citation
|
26 |
_CITATION = """\
|
|
|
52 |
|
53 |
_SOURCE_VERSION = "1.0.0"
|
54 |
|
55 |
+
_SEACROWD_VERSION = "2024.06.20"
|
56 |
|
57 |
|
58 |
class SampiranDataset(datasets.GeneratorBasedBuilder):
|
|
|
60 |
collected from various sources (online)."""
|
61 |
|
62 |
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
63 |
+
SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
|
64 |
|
65 |
BUILDER_CONFIGS = [
|
66 |
+
SEACrowdConfig(
|
67 |
name="sampiran_source",
|
68 |
version=SOURCE_VERSION,
|
69 |
description="sampiran source schema",
|
70 |
schema="source",
|
71 |
subset_id="sampiran",
|
72 |
),
|
73 |
+
SEACrowdConfig(
|
74 |
+
name="sampiran_seacrowd_ssp",
|
75 |
+
version=SEACROWD_VERSION,
|
76 |
description="sampiran Nusantara schema",
|
77 |
+
schema="seacrowd_ssp",
|
78 |
subset_id="sampiran",
|
79 |
),
|
80 |
]
|
|
|
90 |
"pantun": datasets.Value("string"),
|
91 |
}
|
92 |
)
|
93 |
+
elif self.config.schema == "seacrowd_ssp":
|
94 |
# e.g. features = schemas.kb_features
|
95 |
+
# TODO: Choose your seacrowd schema here
|
96 |
features = schemas.self_supervised_pretraining.features
|
97 |
|
98 |
return datasets.DatasetInfo(
|
|
|
121 |
|
122 |
def _generate_examples(self, filepath: Path, split: str = None) -> Tuple[int, Dict]:
|
123 |
"""Yields examples as (key, example) tuples."""
|
124 |
+
if self.config.schema != "source" and self.config.schema != "seacrowd_ssp":
|
125 |
raise ValueError(f"Invalid config schema: {self.config.schema}")
|
126 |
|
127 |
# Read the file line by line
|
|
|
135 |
}
|
136 |
yield id_, ex
|
137 |
|
138 |
+
elif self.config.name == "sampiran_seacrowd_ssp":
|
139 |
with open(filepath, encoding="utf-8") as f:
|
140 |
for id_, row in enumerate(f):
|
141 |
ex = {"id": str(id_), "text": str(row).rstrip()}
|