Datasets:
Update ViHOS.py
Browse files
ViHOS.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
"""ViHOS - Vietnamese Hate and Offensive Spans dataset"""
|
2 |
|
3 |
import pandas as pd
|
|
|
4 |
import datasets
|
5 |
|
6 |
_DESCRIPTION = """\
|
@@ -21,6 +22,7 @@ class ViHOS(datasets.GeneratorBasedBuilder):
|
|
21 |
def _info(self):
|
22 |
return datasets.DatasetInfo(
|
23 |
description=_DESCRIPTION,
|
|
|
24 |
features=datasets.Features(
|
25 |
{
|
26 |
"id": datasets.Value("string"),
|
@@ -28,12 +30,15 @@ class ViHOS(datasets.GeneratorBasedBuilder):
|
|
28 |
"index_spans": datasets.Value("string")
|
29 |
}
|
30 |
),
|
|
|
31 |
homepage=_HOMEPAGE,
|
|
|
32 |
license=_LICENSE
|
33 |
)
|
34 |
|
35 |
def _split_generators(self, dl_manager):
|
36 |
data_dir = dl_manager.download_and_extract(_URLS)
|
|
|
37 |
return [
|
38 |
datasets.SplitGenerator(
|
39 |
name=datasets.Split.TRAIN,
|
@@ -45,5 +50,12 @@ class ViHOS(datasets.GeneratorBasedBuilder):
|
|
45 |
]
|
46 |
|
47 |
def _generate_examples(self, filepath, split):
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
"""ViHOS - Vietnamese Hate and Offensive Spans dataset"""
|
2 |
|
3 |
import pandas as pd
|
4 |
+
|
5 |
import datasets
|
6 |
|
7 |
_DESCRIPTION = """\
|
|
|
22 |
def _info(self):
|
23 |
return datasets.DatasetInfo(
|
24 |
description=_DESCRIPTION,
|
25 |
+
|
26 |
features=datasets.Features(
|
27 |
{
|
28 |
"id": datasets.Value("string"),
|
|
|
30 |
"index_spans": datasets.Value("string")
|
31 |
}
|
32 |
),
|
33 |
+
|
34 |
homepage=_HOMEPAGE,
|
35 |
+
|
36 |
license=_LICENSE
|
37 |
)
|
38 |
|
39 |
def _split_generators(self, dl_manager):
|
40 |
data_dir = dl_manager.download_and_extract(_URLS)
|
41 |
+
|
42 |
return [
|
43 |
datasets.SplitGenerator(
|
44 |
name=datasets.Split.TRAIN,
|
|
|
50 |
]
|
51 |
|
52 |
def _generate_examples(self, filepath, split):
|
53 |
+
colnames=['id', 'Content', 'Span ids']
|
54 |
+
|
55 |
+
with open(filepath, 'r', encoding="utf-8") as f:
|
56 |
+
for i, line in enumerate(f):
|
57 |
+
data = pd.read_csv(f, colnames=colnames, header = None)
|
58 |
+
yield i, data
|
59 |
+
|
60 |
+
# data = pd.read_csv(filepath, colnames=colnames, header = None)
|
61 |
+
# yield data.iloc[:, 0], dataframe.iloc[:, 1], dataframe.iloc[:, 2]
|