File size: 1,425 Bytes
33e8a13
 
fce0648
33e8a13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fce0648
33e8a13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c1c084b
33e8a13
 
 
 
05c7a85
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""ViHOS - Vietnamese Hate and Offensive Spans dataset"""

import pandas as pd
import datasets

_DESCRIPTION = """\
This is a dataset of Vietnamese Hate and Offensive Spans dataset from social media texts.
"""

_HOMEPAGE = "https://huggingface.co/datasets/phusroyal/ViHOS"

_LICENSE = "mit"

_URLS = [
    "https://huggingface.co/datasets/phusroyal/ViHOS/blob/main/train_span_extraction/train.csv"
]

class ViHOS(datasets.GeneratorBasedBuilder):
    VERSION = datasets.Version("2.0.0")

    def _info(self):
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(
                {
                    "id": datasets.Value("string"),
                    "content": datasets.Value("string"),
                    "index_spans": datasets.Value("string")
                }
            ),
            homepage=_HOMEPAGE,
            license=_LICENSE
        )

    def _split_generators(self, dl_manager):
        data_dir = dl_manager.download_and_extract(_URLS)
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={
                    "filepath": data_dir[0],
                    "split": "train",
                },
            )
        ]

    def _generate_examples(self, filepath):
        data = pd.read_csv(filepath)
        yield data.iloc[:, 0], dataframe.iloc[:, 1], dataframe.iloc[:, 2]