import os import glob import datasets class MyDatasetConfig(datasets.BuilderConfig): def __init__(self, data_dir, data_url, **kwargs): super(MyDatasetConfig, self).__init__(**kwargs) self.data_dir = data_dir self.data_url = data_url class MyDataset(datasets.GeneratorBasedBuilder): BUILDER_CONFIGS = [ MyDatasetConfig( name="af", description="af", data_dir="data/af", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/af/", ), MyDatasetConfig( name="ar", description="ar", data_dir="data/ar", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ar/", ), MyDatasetConfig( name="as", description="as", data_dir="data/as", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/as/", ), MyDatasetConfig( name="az", description="az", data_dir="data/az", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/az/", ), MyDatasetConfig( name="be", description="be", data_dir="data/be", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/be/", ), MyDatasetConfig( name="bg", description="bg", data_dir="data/bg", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/bg/", ), MyDatasetConfig( name="bn", description="bn", data_dir="data/bn", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/bn/", ), MyDatasetConfig( name="bn_rom", description="bn_rom", data_dir="data/bn_rom", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/bn_rom/", ), MyDatasetConfig( name="br", description="br", data_dir="data/br", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/br/", ), MyDatasetConfig( name="bs", description="bs", data_dir="data/bs", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/bs/", ), MyDatasetConfig( name="ca", description="ca", data_dir="data/ca", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ca/", ), MyDatasetConfig( name="cs", description="cs", data_dir="data/cs", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/cs/", ), MyDatasetConfig( name="cy", description="cy", data_dir="data/cy", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/cy/", ), MyDatasetConfig( name="da", description="da", data_dir="data/da", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/da/", ), MyDatasetConfig( name="de", description="de", data_dir="data/de", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/de/", ), MyDatasetConfig( name="el", description="el", data_dir="data/el", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/el/", ), MyDatasetConfig( name="en", description="en", data_dir="data/en", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/en/", ), MyDatasetConfig( name="eo", description="eo", data_dir="data/eo", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/eo/", ), MyDatasetConfig( name="es", description="es", data_dir="data/es", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/es/", ), MyDatasetConfig( name="et", description="et", data_dir="data/et", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/et/", ), MyDatasetConfig( name="eu", description="eu", data_dir="data/eu", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/eu/", ), MyDatasetConfig( name="fa", description="fa", data_dir="data/fa", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/fa/", ), MyDatasetConfig( name="ff", description="ff", data_dir="data/ff", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ff/", ), MyDatasetConfig( name="fi", description="fi", data_dir="data/fi", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/fi/", ), MyDatasetConfig( name="fr", description="fr", data_dir="data/fr", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/fr/", ), MyDatasetConfig( name="fy", description="fy", data_dir="data/fy", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/fy/", ), MyDatasetConfig( name="ga", description="ga", data_dir="data/ga", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ga/", ), MyDatasetConfig( name="gd", description="gd", data_dir="data/gd", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/gd/", ), MyDatasetConfig( name="gl", description="gl", data_dir="data/gl", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/gl/", ), MyDatasetConfig( name="gn", description="gn", data_dir="data/gn", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/gn/", ), MyDatasetConfig( name="gu", description="gu", data_dir="data/gu", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/gu/", ), MyDatasetConfig( name="ha", description="ha", data_dir="data/ha", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ha/", ), MyDatasetConfig( name="he", description="he", data_dir="data/he", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/he/", ), MyDatasetConfig( name="hi", description="hi", data_dir="data/hi", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/hi/", ), MyDatasetConfig( name="hi_rom", description="hi_rom", data_dir="data/hi_rom", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/hi_rom/", ), MyDatasetConfig( name="hr", description="hr", data_dir="data/hr", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/hr/", ), MyDatasetConfig( name="ht", description="ht", data_dir="data/ht", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ht/", ), MyDatasetConfig( name="hu", description="hu", data_dir="data/hu", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/hu/", ), MyDatasetConfig( name="hy", description="hy", data_dir="data/hy", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/hy/", ), MyDatasetConfig( name="id", description="id", data_dir="data/id", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/id/", ), MyDatasetConfig( name="ig", description="ig", data_dir="data/ig", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ig/", ), MyDatasetConfig( name="is", description="is", data_dir="data/is", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/is/", ), MyDatasetConfig( name="it", description="it", data_dir="data/it", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/it/", ), MyDatasetConfig( name="ja", description="ja", data_dir="data/ja", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ja/", ), MyDatasetConfig( name="jv", description="jv", data_dir="data/jv", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/jv/", ), MyDatasetConfig( name="ka", description="ka", data_dir="data/ka", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ka/", ), MyDatasetConfig( name="kk", description="kk", data_dir="data/kk", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/kk/", ), MyDatasetConfig( name="km", description="km", data_dir="data/km", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/km/", ), MyDatasetConfig( name="kn", description="kn", data_dir="data/kn", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/kn/", ), MyDatasetConfig( name="ko", description="ko", data_dir="data/ko", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ko/", ), MyDatasetConfig( name="ku", description="ku", data_dir="data/ku", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ku/", ), MyDatasetConfig( name="ky", description="ky", data_dir="data/ky", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ky/", ), MyDatasetConfig( name="la", description="la", data_dir="data/la", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/la/", ), MyDatasetConfig( name="lg", description="lg", data_dir="data/lg", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/lg/", ), MyDatasetConfig( name="li", description="li", data_dir="data/li", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/li/", ), MyDatasetConfig( name="ln", description="ln", data_dir="data/ln", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ln/", ), MyDatasetConfig( name="lo", description="lo", data_dir="data/lo", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/lo/", ), MyDatasetConfig( name="lt", description="lt", data_dir="data/lt", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/lt/", ), MyDatasetConfig( name="lv", description="lv", data_dir="data/lv", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/lv/", ), MyDatasetConfig( name="mg", description="mg", data_dir="data/mg", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/mg/", ), MyDatasetConfig( name="mk", description="mk", data_dir="data/mk", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/mk/", ), MyDatasetConfig( name="ml", description="ml", data_dir="data/ml", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ml/", ), MyDatasetConfig( name="mn", description="mn", data_dir="data/mn", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/mn/", ), MyDatasetConfig( name="mr", description="mr", data_dir="data/mr", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/mr/", ), MyDatasetConfig( name="ms", description="ms", data_dir="data/ms", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ms/", ), MyDatasetConfig( name="my", description="my", data_dir="data/my", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/my/", ), MyDatasetConfig( name="my_zaw", description="my_zaw", data_dir="data/my_zaw", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/my_zaw/", ), MyDatasetConfig( name="ne", description="ne", data_dir="data/ne", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ne/", ), MyDatasetConfig( name="nl", description="nl", data_dir="data/nl", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/nl/", ), MyDatasetConfig( name="no", description="no", data_dir="data/no", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/no/", ), MyDatasetConfig( name="ns", description="ns", data_dir="data/ns", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ns/", ), MyDatasetConfig( name="om", description="om", data_dir="data/om", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/om/", ), MyDatasetConfig( name="or", description="or", data_dir="data/or", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/or/", ), MyDatasetConfig( name="pa", description="pa", data_dir="data/pa", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/pa/", ), MyDatasetConfig( name="pl", description="pl", data_dir="data/pl", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/pl/", ), MyDatasetConfig( name="ps", description="ps", data_dir="data/ps", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ps/", ), MyDatasetConfig( name="pt", description="pt", data_dir="data/pt", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/pt/", ), MyDatasetConfig( name="qu", description="qu", data_dir="data/qu", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/qu/", ), MyDatasetConfig( name="rm", description="rm", data_dir="data/rm", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/rm/", ), MyDatasetConfig( name="ro", description="ro", data_dir="data/ro", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ro/", ), MyDatasetConfig( name="ru", description="ru", data_dir="data/ru", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ru/", ), MyDatasetConfig( name="sa", description="sa", data_dir="data/sa", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/sa/", ), MyDatasetConfig( name="sc", description="sc", data_dir="data/sc", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/sc/", ), MyDatasetConfig( name="sd", description="sd", data_dir="data/sd", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/sd/", ), MyDatasetConfig( name="si", description="si", data_dir="data/si", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/si/", ), MyDatasetConfig( name="sk", description="sk", data_dir="data/sk", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/sk/", ), MyDatasetConfig( name="sl", description="sl", data_dir="data/sl", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/sl/", ), MyDatasetConfig( name="so", description="so", data_dir="data/so", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/so/", ), MyDatasetConfig( name="sq", description="sq", data_dir="data/sq", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/sq/", ), MyDatasetConfig( name="sr", description="sr", data_dir="data/sr", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/sr/", ), MyDatasetConfig( name="ss", description="ss", data_dir="data/ss", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ss/", ), MyDatasetConfig( name="su", description="su", data_dir="data/su", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/su/", ), MyDatasetConfig( name="sv", description="sv", data_dir="data/sv", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/sv/", ), MyDatasetConfig( name="sw", description="sw", data_dir="data/sw", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/sw/", ), MyDatasetConfig( name="ta", description="ta", data_dir="data/ta", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ta/", ), MyDatasetConfig( name="ta_rom", description="ta_rom", data_dir="data/ta_rom", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ta_rom/", ), MyDatasetConfig( name="te", description="te", data_dir="data/te", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/te/", ), MyDatasetConfig( name="te_rom", description="te_rom", data_dir="data/te_rom", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/te_rom/", ), MyDatasetConfig( name="th", description="th", data_dir="data/th", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/th/", ), MyDatasetConfig( name="tl", description="tl", data_dir="data/tl", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/tl/", ), MyDatasetConfig( name="tn", description="tn", data_dir="data/tn", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/tn/", ), MyDatasetConfig( name="tr", description="tr", data_dir="data/tr", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/tr/", ), MyDatasetConfig( name="ug", description="ug", data_dir="data/ug", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ug/", ), MyDatasetConfig( name="uk", description="uk", data_dir="data/uk", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/uk/", ), MyDatasetConfig( name="ur", description="ur", data_dir="data/ur", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ur/", ), MyDatasetConfig( name="ur_rom", description="ur_rom", data_dir="data/ur_rom", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/ur_rom/", ), MyDatasetConfig( name="uz", description="uz", data_dir="data/uz", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/uz/", ), MyDatasetConfig( name="vi", description="vi", data_dir="data/vi", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/vi/", ), MyDatasetConfig( name="wo", description="wo", data_dir="data/wo", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/wo/", ), MyDatasetConfig( name="xh", description="xh", data_dir="data/xh", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/xh/", ), MyDatasetConfig( name="yi", description="yi", data_dir="data/yi", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/yi/", ), MyDatasetConfig( name="yo", description="yo", data_dir="data/yo", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/yo/", ), MyDatasetConfig( name="zh-Hans", description="zh-Hans", data_dir="data/zh-Hans", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/zh-Hans/", ), MyDatasetConfig( name="zh-Hant", description="zh-Hant", data_dir="data/zh-Hant", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/zh-Hant/", ), MyDatasetConfig( name="zu", description="zu", data_dir="data/zu", data_url="https://huggingface.co/datasets/bowphs/cc-100-01-percent/data/zu/", ) ] DEFAULT_CONFIG_NAME = "en" def _info(self): return datasets.DatasetInfo( features=datasets.Features({ "text": datasets.Value("string"), }), supervised_keys=None, ) def _split_generators(self, dl_manager): train_url = "train.txt" test_url = "test.txt" valid_url = "valid.txt" train_path = dl_manager.download(os.path.join(self.config.data_dir, train_url)) test_path = dl_manager.download(os.path.join(self.config.data_dir, test_url)) valid_path = dl_manager.download(os.path.join(self.config.data_dir, valid_url)) return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}, ), datasets.SplitGenerator( name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}, ), datasets.SplitGenerator( name=datasets.Split.VALIDATION, gen_kwargs={"filepath": valid_path}, ), ] def _generate_examples(self, filepath): with open(filepath, encoding="utf-8") as f: for id_, line in enumerate(f): yield id_, {"text": line.strip()}