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, }