holylovenia
commited on
Upload id_abusive.py with huggingface_hub
Browse files- id_abusive.py +12 -12
id_abusive.py
CHANGED
@@ -4,9 +4,9 @@ from typing import Dict, List, Tuple
|
|
4 |
import datasets
|
5 |
import pandas as pd
|
6 |
|
7 |
-
from
|
8 |
-
from
|
9 |
-
from
|
10 |
|
11 |
_CITATION = """\
|
12 |
@article{IBROHIM2018222,
|
@@ -43,7 +43,7 @@ _URLS = {
|
|
43 |
}
|
44 |
_SUPPORTED_TASKS = [Tasks.SENTIMENT_ANALYSIS]
|
45 |
_SOURCE_VERSION = "1.0.0"
|
46 |
-
|
47 |
|
48 |
|
49 |
class IdAbusive(datasets.GeneratorBasedBuilder):
|
@@ -51,7 +51,7 @@ class IdAbusive(datasets.GeneratorBasedBuilder):
|
|
51 |
not abusive language, abusive but not offensive, and offensive language."""
|
52 |
|
53 |
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
54 |
-
|
55 |
LABEL_STRING_MAP = {
|
56 |
1: "not_abusive",
|
57 |
2: "abusive",
|
@@ -59,18 +59,18 @@ class IdAbusive(datasets.GeneratorBasedBuilder):
|
|
59 |
}
|
60 |
|
61 |
BUILDER_CONFIGS = [
|
62 |
-
|
63 |
name="id_abusive_source",
|
64 |
version=SOURCE_VERSION,
|
65 |
description="ID Abusive source schema",
|
66 |
schema="source",
|
67 |
subset_id="id_abusive",
|
68 |
),
|
69 |
-
|
70 |
-
name="
|
71 |
-
version=
|
72 |
description="ID Abusive Nusantara schema",
|
73 |
-
schema="
|
74 |
subset_id="id_abusive",
|
75 |
),
|
76 |
]
|
@@ -80,7 +80,7 @@ class IdAbusive(datasets.GeneratorBasedBuilder):
|
|
80 |
def _info(self) -> datasets.DatasetInfo:
|
81 |
if self.config.schema == "source":
|
82 |
features = datasets.Features({"tweet": datasets.Value("string"), "label": datasets.Value("string")})
|
83 |
-
elif self.config.schema == "
|
84 |
features = schemas.text_features(["not_abusive", "abusive", "abusive_and_offensive"])
|
85 |
|
86 |
return datasets.DatasetInfo(
|
@@ -122,7 +122,7 @@ class IdAbusive(datasets.GeneratorBasedBuilder):
|
|
122 |
}
|
123 |
yield row.id, ex
|
124 |
|
125 |
-
elif self.config.schema == "
|
126 |
for row in df.itertuples():
|
127 |
ex = {
|
128 |
"id": str(row.id),
|
|
|
4 |
import datasets
|
5 |
import pandas as pd
|
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{IBROHIM2018222,
|
|
|
43 |
}
|
44 |
_SUPPORTED_TASKS = [Tasks.SENTIMENT_ANALYSIS]
|
45 |
_SOURCE_VERSION = "1.0.0"
|
46 |
+
_SEACROWD_VERSION = "2024.06.20"
|
47 |
|
48 |
|
49 |
class IdAbusive(datasets.GeneratorBasedBuilder):
|
|
|
51 |
not abusive language, abusive but not offensive, and offensive language."""
|
52 |
|
53 |
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
54 |
+
SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
|
55 |
LABEL_STRING_MAP = {
|
56 |
1: "not_abusive",
|
57 |
2: "abusive",
|
|
|
59 |
}
|
60 |
|
61 |
BUILDER_CONFIGS = [
|
62 |
+
SEACrowdConfig(
|
63 |
name="id_abusive_source",
|
64 |
version=SOURCE_VERSION,
|
65 |
description="ID Abusive source schema",
|
66 |
schema="source",
|
67 |
subset_id="id_abusive",
|
68 |
),
|
69 |
+
SEACrowdConfig(
|
70 |
+
name="id_abusive_seacrowd_text",
|
71 |
+
version=SEACROWD_VERSION,
|
72 |
description="ID Abusive Nusantara schema",
|
73 |
+
schema="seacrowd_text",
|
74 |
subset_id="id_abusive",
|
75 |
),
|
76 |
]
|
|
|
80 |
def _info(self) -> datasets.DatasetInfo:
|
81 |
if self.config.schema == "source":
|
82 |
features = datasets.Features({"tweet": datasets.Value("string"), "label": datasets.Value("string")})
|
83 |
+
elif self.config.schema == "seacrowd_text":
|
84 |
features = schemas.text_features(["not_abusive", "abusive", "abusive_and_offensive"])
|
85 |
|
86 |
return datasets.DatasetInfo(
|
|
|
122 |
}
|
123 |
yield row.id, ex
|
124 |
|
125 |
+
elif self.config.schema == "seacrowd_text":
|
126 |
for row in df.itertuples():
|
127 |
ex = {
|
128 |
"id": str(row.id),
|