File size: 1,703 Bytes
30143df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import csv

import datasets

_DESCRIPTION = """\
Japanese stopwords for nagisa.
"""

_HOMEPAGE = "https://github.com/taishi-i/nagisa"
_CITATION = ""
_LICENSE = "MIT"


class NagisaStopwordsDataset(datasets.GeneratorBasedBuilder):
    """Japanese stopwords for nagisa."""

    VERSION = datasets.Version("0.0.1")
    BUILDER_CONFIGS = [
        datasets.BuilderConfig(
            name="nagisa_stopwords",
            version=VERSION,
            description=_DESCRIPTION,
        ),
    ]

    def _info(self):
        features = datasets.Features(
            {
                "words": datasets.Value("string"),
                "postags": datasets.Value("string"),
            }
        )

        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=features,
            homepage=_HOMEPAGE,
            license=_LICENSE,
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        data_url = "nagisa_stopwords.csv"
        return [
            datasets.SplitGenerator(
                name="nagisa_stopwords",
                gen_kwargs={
                    "filepath": dl_manager.download_and_extract(data_url),
                    "split": "words",
                },
            )
        ]

    def _generate_examples(self, filepath, split):
        """Generates examples."""
        with open(filepath, "r", encoding="utf-8") as f:
            reader = csv.reader(f)
            next(reader)  # Skip the header row
            for id_, row in enumerate(reader):
                words, postags = row
                yield id_, {
                    "words": words,
                    "postags": postags,
                }