holylovenia
commited on
Commit
•
2d6c79a
1
Parent(s):
2d75368
Upload id_clickbait.py with huggingface_hub
Browse files- id_clickbait.py +12 -12
id_clickbait.py
CHANGED
@@ -4,9 +4,9 @@ from typing import Dict, List, Tuple
|
|
4 |
|
5 |
import datasets
|
6 |
|
7 |
-
from
|
8 |
-
from
|
9 |
-
from
|
10 |
|
11 |
_CITATION = """\
|
12 |
@article{WILLIAM2020106231,
|
@@ -42,28 +42,28 @@ _URLS = {
|
|
42 |
}
|
43 |
_SUPPORTED_TASKS = [Tasks.SENTIMENT_ANALYSIS]
|
44 |
_SOURCE_VERSION = "1.0.0"
|
45 |
-
|
46 |
|
47 |
|
48 |
class IdClickbait(datasets.GeneratorBasedBuilder):
|
49 |
"""The CLICK-ID dataset is a collection of Indonesian news headlines that was collected from 12 local online news, annotated with a label whether each is a clickbait"""
|
50 |
|
51 |
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
52 |
-
|
53 |
|
54 |
BUILDER_CONFIGS = [
|
55 |
-
|
56 |
name="id_clickbait_source",
|
57 |
version=SOURCE_VERSION,
|
58 |
description="CLICK-ID source schema",
|
59 |
schema="source",
|
60 |
subset_id="id_clickbait",
|
61 |
),
|
62 |
-
|
63 |
-
name="
|
64 |
-
version=
|
65 |
description="CLICK-ID Nusantara schema",
|
66 |
-
schema="
|
67 |
subset_id="id_clickbait",
|
68 |
),
|
69 |
]
|
@@ -73,7 +73,7 @@ class IdClickbait(datasets.GeneratorBasedBuilder):
|
|
73 |
def _info(self) -> datasets.DatasetInfo:
|
74 |
if self.config.schema == "source":
|
75 |
features = datasets.Features({"title": datasets.Value("string"), "label": datasets.Value("string"), "label_score": datasets.Value("int8")})
|
76 |
-
elif self.config.schema == "
|
77 |
features = schemas.text_features(["non-clickbait", "clickbait"])
|
78 |
|
79 |
return datasets.DatasetInfo(
|
@@ -115,7 +115,7 @@ class IdClickbait(datasets.GeneratorBasedBuilder):
|
|
115 |
}
|
116 |
yield row_index, ex
|
117 |
|
118 |
-
elif self.config.schema == "
|
119 |
for row_index, row in enumerate(data):
|
120 |
ex = {
|
121 |
"id": str(row_index),
|
|
|
4 |
|
5 |
import datasets
|
6 |
|
7 |
+
from seacrowd.utils import schemas
|
8 |
+
from seacrowd.utils.configs import SEACrowdConfig
|
9 |
+
from seacrowd.utils.constants import Tasks
|
10 |
|
11 |
_CITATION = """\
|
12 |
@article{WILLIAM2020106231,
|
|
|
42 |
}
|
43 |
_SUPPORTED_TASKS = [Tasks.SENTIMENT_ANALYSIS]
|
44 |
_SOURCE_VERSION = "1.0.0"
|
45 |
+
_SEACROWD_VERSION = "2024.06.20"
|
46 |
|
47 |
|
48 |
class IdClickbait(datasets.GeneratorBasedBuilder):
|
49 |
"""The CLICK-ID dataset is a collection of Indonesian news headlines that was collected from 12 local online news, annotated with a label whether each is a clickbait"""
|
50 |
|
51 |
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
52 |
+
SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
|
53 |
|
54 |
BUILDER_CONFIGS = [
|
55 |
+
SEACrowdConfig(
|
56 |
name="id_clickbait_source",
|
57 |
version=SOURCE_VERSION,
|
58 |
description="CLICK-ID source schema",
|
59 |
schema="source",
|
60 |
subset_id="id_clickbait",
|
61 |
),
|
62 |
+
SEACrowdConfig(
|
63 |
+
name="id_clickbait_seacrowd_text",
|
64 |
+
version=SEACROWD_VERSION,
|
65 |
description="CLICK-ID Nusantara schema",
|
66 |
+
schema="seacrowd_text",
|
67 |
subset_id="id_clickbait",
|
68 |
),
|
69 |
]
|
|
|
73 |
def _info(self) -> datasets.DatasetInfo:
|
74 |
if self.config.schema == "source":
|
75 |
features = datasets.Features({"title": datasets.Value("string"), "label": datasets.Value("string"), "label_score": datasets.Value("int8")})
|
76 |
+
elif self.config.schema == "seacrowd_text":
|
77 |
features = schemas.text_features(["non-clickbait", "clickbait"])
|
78 |
|
79 |
return datasets.DatasetInfo(
|
|
|
115 |
}
|
116 |
yield row_index, ex
|
117 |
|
118 |
+
elif self.config.schema == "seacrowd_text":
|
119 |
for row_index, row in enumerate(data):
|
120 |
ex = {
|
121 |
"id": str(row_index),
|